update operation library

This commit is contained in:
qiurui 2024-01-09 11:24:25 +08:00
parent 3002ae370e
commit 198d363b8c
2 changed files with 27 additions and 5 deletions

View File

@ -16,7 +16,7 @@ def get_commits_commit_count(commit1,commit2):
#获取两个commit之间的hash列表
def get_commit_hash(commit1,commit2):
cmd = "git log" + " '" + commit1 + "'.." + commit2 + " --oneline --pretty=format:'%h'"
cmd = "git log" + " " + commit1 + ".." + commit2 + " --oneline --pretty=format:'%h'"
hash = []
multiline_str = os.popen(cmd)
for line in multiline_str.readlines():
@ -56,8 +56,12 @@ def get_commit_body(hash):
return preprocessed
#获取某个commit的修改文件
def get_commit_diff_files(hash_list,hash_commit):
num = list.index(hash_list)
def get_commit_diff_files(hash_commit):
cmd = "git log" + " " + hash_commit + " -2 --oneline --pretty=format:'%h'"
hash = []
multiline_str = os.popen(cmd)
for line in multiline_str.readlines():
hash.append(line.replace('\n',''))
cmd = "git diff" + " --name-only " + hash[1] + " " + hash[0]
process = os.popen(cmd)
preprocessed = process.read()

View File

@ -1,14 +1,32 @@
from pygitlog.gitoperation import *
import sys
def mkdir(path):
# 去除首位空格
path=path.strip()
# 去除尾部 \ 符号
path=path.rstrip("\\")
# 判断路径是否存在
isExists=os.path.exists(path)
# 判断结果
if not isExists:
os.makedirs(path)
print (path + " 创建成功")
else:
# 如果目录存在则不创建,并提示目录已存在
print (path + " 目录已存在")
def initmd(version1,version2,source):
filename = source + version1 + "_" + version2 + ".md"
dir = os.getcwd() + "/output/"
mkdir(dir)
filename = dir + source + version1 + "_" + version2 + ".md"
with open(filename,mode="w") as file:
file.write("# kernel log summary\n")
file.write("## " + source + " from " + version1 + " to " + version2 + "\n")
file.write("| hash | time | editor | email | body | type | keywords | diff-files | \n")
file.write("| :---- | :---- | :---- | :---- | :--- | :---- | :------- | :--------- | \n")
os.chmod(filename,448)
return os.getcwd() + "/" + filename
return filename
def format(str):