Skip to content

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

Description

@bytefluxio

Am I missing something or is that currently missing?

The git command would be git cat-file commit {git_hash}.

I used the following before using GitPython:

def git_hash_is_valid(git_hash):
    return subprocess_return_call(f"git cat-file commit {git_hash}") == 0

def subprocess_return_call(call_string):
    call_parameters = call_string.split(" ")
    return subprocess.call(
        call_parameters,
        stderr=subprocess.STDOUT,
        stdout=open(os.devnull, 'w')
    )

Would a method like that fit into repo directly like repo.is_ancestor()?

I know self.repo.commit( works, but that does not differentiate between refs and commit hashes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions