Skip to content

GitPython does not contain a 'is_valid_hash' method. #1266

Answered by Byron
bytefluxio asked this question in Q&A
Discussion options

You must be logged in to vote

The fastest way to do this is this one:

oinfo = repo.odb.info(sha1)

As it will call git cat-file under the hood it might be that other forms of rev names are also supported, like branch names and the likes. It's certainly something to test out if that's a problem in this case.

A PR is welcome in case you would like to add a method to test for an objects existence on a Repo.

Replies: 3 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by Byron
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #1265 on June 05, 2021 02:15.