मैं pygit2 का उपयोग कर गिट नंगे भंडार में git log filename
के बराबर करने की कोशिश कर रहा हूं। प्रलेखन केवल बताते हैं कि कैसे एक git log
इस तरह करना है:pygit2 ब्लॉब इतिहास
from pygit2 import GIT_SORT_TIME
for commit in repo.walk(oid, GIT_SORT_TIME):
print(commit.hex)
आप किसी भी विचार है?
धन्यवाद
संपादित करें:
from pygit2 import GIT_SORT_TIME, Repository
repo = Repository('/path/to/repo')
def iter_commits(name):
last_commit = None
last_oid = None
# loops through all the commits
for commit in repo.walk(repo.head.oid, GIT_SORT_TIME):
# checks if the file exists
if name in commit.tree:
# has it changed since last commit?
# let's compare it's sha with the previous found sha
oid = commit.tree[name].oid
has_changed = (oid != last_oid and last_oid)
if has_changed:
yield last_commit
last_oid = oid
else:
last_oid = None
last_commit = commit
if last_oid:
yield last_commit
for commit in iter_commits("AUTHORS"):
print(commit.message, commit.author.name, commit.commit_time)