get_head* -> get_head_commit*

This commit is contained in:
Paul Gauthier 2024-08-31 07:35:55 -07:00
parent d2acb9c3b0
commit 3b9e000892
3 changed files with 14 additions and 14 deletions

View file

@ -138,7 +138,7 @@ class GitRepo:
os.environ["GIT_AUTHOR_NAME"] = committer_name
self.repo.git.commit(cmd)
commit_hash = self.get_head_sha(short=True)
commit_hash = self.get_head_commit_sha(short=True)
self.io.tool_output(f"Commit {commit_hash} {commit_message}", bold=True)
# Restore the env
@ -373,22 +373,22 @@ class GitRepo:
return self.repo.is_dirty(path=path)
def get_head(self):
def get_head_commit(self):
try:
return self.repo.head.commit
except (ValueError, gitdb.exc.ODBError):
return None
def get_head_sha(self, short=False):
commit = self.get_head()
def get_head_commit_sha(self, short=False):
commit = self.get_head_commit()
if not commit:
return
if short:
return commit.hexsha[:7]
return commit.hexsha
def get_head_message(self, default=None):
commit = self.get_head()
def get_head_commit_message(self, default=None):
commit = self.get_head_commit()
if not commit:
return default
return commit.message