Skip to content

Commit 36d490e

Browse files
author
pulkit.si
committed
Move the printing commit information to a separate function
1 parent 95908d3 commit 36d490e

File tree

2 files changed

+11
-12
lines changed

2 files changed

+11
-12
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
.env/
22
__pycache__/
3+
ignored_hashes.db

gitdifflog.py

+10-12
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,14 @@
3939
commitsInFirst = list(repo.iter_commits(args.first))
4040
commitsInSecond = list(repo.iter_commits(args.second))
4141

42+
def printCommitInformation(commit):
43+
print(colored("commit {}".format(commit.hexsha), 'yellow'))
44+
print("Author: {} <{}>".format(commit.author.name, commit.author.email))
45+
print("Date : {}".format(time.strftime("%c %Z", time.localtime(commit.authored_date))))
46+
print()
47+
print("\t{}".format(commit.message.strip()))
48+
print()
49+
4250
commitsDifference = []
4351
for commit in commitsInFirst:
4452
commitMessage = commit.message
@@ -55,21 +63,11 @@
5563
if not args.r:
5664
for commit in commitsDifference:
5765
if not ignoredHashes.isPresent(commit.hexsha):
58-
print(colored("commit {}".format(commit.hexsha), 'yellow'))
59-
print("Author: {} <{}>".format(commit.author.name, commit.author.email))
60-
print("Date : {}".format(time.strftime("%c %Z", time.localtime(commit.authored_date))))
61-
print()
62-
print("\t{}".format(commit.message.strip()))
63-
print()
66+
printCommitInformation(commit)
6467
else:
6568
for commit in commitsDifference:
6669
if not ignoredHashes.isPresent(commit.hexsha):
67-
print(colored("commit {}".format(commit.hexsha), 'yellow'))
68-
print("Author: {} <{}>".format(commit.author.name, commit.author.email))
69-
print("Date : {}".format(time.strftime("%c %Z", time.localtime(commit.authored_date))))
70-
print()
71-
print("\t{}".format(commit.message.strip()))
72-
print()
70+
printCommitInformation(commit)
7371
while True:
7472
inp = input("Resolve[R] / Ignore[I] : ")
7573
if inp.upper() == 'I':

0 commit comments

Comments
 (0)