2

レポのブランチ全体をコミットする必要があります。私はこれを試しましたが、成功しませんでした。:

for branch_name in list(repo.branches.remote):
   try:
        branch = repo.lookup_branch(branch_name)
        ref = repo.lookup_reference(branch.name)
        repo.checkout(ref)

        for commit in repo.walk(branch.target, pygit2.GIT_SORT_TIME):
            print(commit.id.hex)

どんな助けでも感謝します、ありがとう。

4

1 に答える 1

0

これは私が持っているものです:

def iterate_repository(dir: str) -> None:
    repo = pygit2.Repository(dir)
    for branch_name in list(repo.branches.remote):
        branch = repo.branches.get(branch_name)
        latest_commit_id = branch.target
        latest_commit = repo.revparse_single(latest_commit_id.hex)

        for commit in repo.walk(latest_commit.id, pygit2.GIT_SORT_TIME):
            print(commit.id.hex)

そこからの拡張は比較的簡単なはずです。私がしているのは、コミットに含まれるファイルから統計を収集することです。

于 2021-07-21T12:21:01.113 に答える