Skip to content

How to check if a commit exists? #721

Closed
@strokirk

Description

@strokirk

Like the title says. I'd like to check if a specific commit exists.
Trying to run iter_commits over a rev that doesn't exists throws an exception, and I'd like to avoid that in order to provide nicer user output for my script.

Pseudocode:

if repo.exists(source):
    return list(repo.iter_commits("%s...%s" % (source, target)))
else:
    print("Couldn't find %s, you need to run git fetch")

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