25
我試圖訪問提交單個文件的歷史,如:git的日誌--follow的gitpython方式
git log --follow -- <filename>
我不得不使用gitpython,所以我現在正在做的是:
import git
g = git.Git('repo_dir')
hexshas = g.log('--pretty=%H','--follow','--',filename).split('\n')
然後我建對象提交:
repo = git.Repo('repo_dir')
commits = [repo.rev_parse(c) for c in r]
有沒有辦法做到這一點更gitpython-IC的方式? 我試過commit.iter_parents()
和commit.iter_items()
,但他們都依靠git-rev-list
,所以他們沒有--follow
選項。