Closed yindaheng98 closed 4 years ago
I have encountered the same issue (but running in GitLab)
This might be the same issue as https://github.com/AArnott/Nerdbank.GitVersioning/issues/174: walking all commits require a full clone of the repository, not a shallow one.
In Travis CI, the shallow clone is disabled with the following YAML configuration:
git:
depth: false
However, in my case the code is literally this:
for commit in git.walk(git.head.target, GIT_SORT_TOPOLOGICAL):
return commit.message
Is there any other way I could get the message of the latest commit on the current branch?
I am not familiar with the Python bindings of libgit2, but you should be able to peel the head reference to a commit, without having to walk the history. Something like this:
return git.head.peel(pygit2.Commit).message
To get the commit's time or message you need to load the object, if the object is not in the database it will fail. This may happen for example with shallow clones and with submodules (see issue #967).
This works as well:
repo.head.peel().commit_time
repo.head.peel().message
In any case be sure to use the latest version of pygit2 1.1.1, or at least 1.0.3
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:
And this error was throw from:
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