diff --git a/src/darker/git.py b/src/darker/git.py index d259e8b04..328857294 100644 --- a/src/darker/git.py +++ b/src/darker/git.py @@ -33,6 +33,16 @@ PRE_COMMIT_FROM_TO_REFS = ":PRE-COMMIT:" +def git_rev_parse(revision: str, cwd: Path) -> str: + """Return the commit hash for the given revision + + :param revision: The revision to get the commit hash for + :param cwd: The root of the Git repository + + """ + return _git_check_output_lines(["rev-parse", revision], cwd)[0] + + def git_rev_parse(revision: str, cwd: Path) -> str: """Return the commit hash for the given revision