1. search_all_effective_commit_include_reverted
def remember_commit(file_name, commit_id):
print "remember_commit:"
print commit_id;
read = file(file_name,'a+')
read.write(commit_id)
read.write("\n")
read.close()
def search_all_effective_commit_include_reverted():
commit_tag = "commit"
commit_len = 6
commit_begin = False
# not found
found = -1
read = open("git.log")
key_not_check = ("Revert", "Other")
record_commit = True;
commit_id = "start:";
line=read.readline()
while line:
equal = cmp(line[0:commit_len],commit_tag)
if equal == 0:
if record_commit == True:
remember_commit("commit_found", commit_id)
else:
print "find record_commit is false"
record_commit = True
commit_id = line[7:]
else:
for i in range(2):
found = line.find(key_not_check[i])
if found >= 0:
print "found integrate or revert"
record_commit = False
line=read.readline()
2. output name-status for each commit to file_list
def produce_file_list():
read = open("commit_found")
line=read.readline()
while line:
if len(line) > 1:
command = "git show "
line = line.strip('\n')
command += line
command += " --name-status --oneline >> ~/file_list.txt"
print command
commands.getoutput(command)
line=read.readline()
read.close()
3. thought file status, to put file name into different kind record.txt
def write_to_file(file_name,line):
read = file(file_name,'a+')
read.write(line)
read.write("\n")
read.close()
def format_file_list():
read = open("/home/demo/file_list.txt")
line=read.readline()
str_name = ""
while line:
if cmp(line[0], 'M') == 0:
str_name = line[1:].strip()
print str_name
write_to_file("/home/demo/m.txt",str_name)
if cmp(line[0], 'A') == 0:
str_name = line[1:].strip()
print str_name
write_to_file("/home/demo/a.txt",str_name)
if cmp(line[0], 'D') == 0:
str_name = line[1:].strip()
print str_name
write_to_file("/home/demo/d.txt",str_name)
line=read.readline()
read.close()
4. manualy remove reverted files from git.log, this can be programed in future.
it is complicated, for there is double revert.
def remember_commit(file_name, commit_id):
print "remember_commit:"
print commit_id;
read = file(file_name,'a+')
read.write(commit_id)
read.write("\n")
read.close()
def search_all_effective_commit_include_reverted():
commit_tag = "commit"
commit_len = 6
commit_begin = False
# not found
found = -1
read = open("git.log")
key_not_check = ("Revert", "Other")
record_commit = True;
commit_id = "start:";
line=read.readline()
while line:
equal = cmp(line[0:commit_len],commit_tag)
if equal == 0:
if record_commit == True:
remember_commit("commit_found", commit_id)
else:
print "find record_commit is false"
record_commit = True
commit_id = line[7:]
else:
for i in range(2):
found = line.find(key_not_check[i])
if found >= 0:
print "found integrate or revert"
record_commit = False
line=read.readline()
2. output name-status for each commit to file_list
def produce_file_list():
read = open("commit_found")
line=read.readline()
while line:
if len(line) > 1:
command = "git show "
line = line.strip('\n')
command += line
command += " --name-status --oneline >> ~/file_list.txt"
print command
commands.getoutput(command)
line=read.readline()
read.close()
3. thought file status, to put file name into different kind record.txt
def write_to_file(file_name,line):
read = file(file_name,'a+')
read.write(line)
read.write("\n")
read.close()
def format_file_list():
read = open("/home/demo/file_list.txt")
line=read.readline()
str_name = ""
while line:
if cmp(line[0], 'M') == 0:
str_name = line[1:].strip()
print str_name
write_to_file("/home/demo/m.txt",str_name)
if cmp(line[0], 'A') == 0:
str_name = line[1:].strip()
print str_name
write_to_file("/home/demo/a.txt",str_name)
if cmp(line[0], 'D') == 0:
str_name = line[1:].strip()
print str_name
write_to_file("/home/demo/d.txt",str_name)
line=read.readline()
read.close()
4. manualy remove reverted files from git.log, this can be programed in future.
it is complicated, for there is double revert.

本文介绍了一款用于分析Git日志的工具,该工具能够记录有效的提交(包括撤销的提交),并能输出每个提交涉及的文件状态到指定文件中。此外,还提供了将不同状态的文件名归类记录的功能。
4287

被折叠的 条评论
为什么被折叠?



