Skip to content

object not found and KeyError when scanning commits #949

@yindaheng98

Description

@yindaheng98

Hi there, I'm using a python 3.7.2 and pygit2 in TravisCI for building and deploying my github pages. The python script is used to scan all the commit and find the latest commit time for every file. But now I got an error in TravisCI when building, just like this:

Traceback (most recent call last):
  File "travisPorcess.py", line 1, in <module>
    from meta import meta_data, path
  File "/home/travis/build/yindaheng98/My-docs/meta.py", line 5, in <module>
    from getDate import data
  File "/home/travis/build/yindaheng98/My-docs/getDate.py", line 71, in <module>
    for commit in commits:
KeyError: 'object not found - no match for id (c170b110850200770e9c0d1b35b2616dfe18614d)'

And this error was throw from:

repo = pygit2.Repository('./')
commits=repo.walk(repo.head.target,GIT_SORT_TOPOLOGICAL|GIT_SORT_REVERSE)

last_tree=None
for commit in commits:#<<<<<<<<-throw from here
    date=time.gmtime(commit.commit_time)
    date=time.strftime('%Y-%m-%d %H:%M:%S',date)
    print("scanning commit %s at %s"%(commit.message,date))

    tree=commit.tree
    if last_tree is None:
        last_tree=tree
        continue

    diff=tree.diff_to_tree(last_tree)
    updateData(date,diff)
    last_tree=tree

This error is only appear in TravisCI, it can done its work properly in my Notebook.

Is this error caused by bugs? Or just my improper usage?

PS: The complete python scripts is here

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions