mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-25 06:44:59 +00:00
get_head* -> get_head_commit*
This commit is contained in:
parent
d2acb9c3b0
commit
3b9e000892
3 changed files with 14 additions and 14 deletions
|
@ -713,7 +713,7 @@ class Coder:
|
||||||
self.shell_commands = []
|
self.shell_commands = []
|
||||||
|
|
||||||
if self.repo:
|
if self.repo:
|
||||||
self.commit_before_message.append(self.repo.get_head_sha())
|
self.commit_before_message.append(self.repo.get_head_commit_sha())
|
||||||
|
|
||||||
def run(self, with_message=None, preproc=True):
|
def run(self, with_message=None, preproc=True):
|
||||||
try:
|
try:
|
||||||
|
@ -1867,7 +1867,7 @@ class Coder:
|
||||||
def show_undo_hint(self):
|
def show_undo_hint(self):
|
||||||
if not self.commit_before_message:
|
if not self.commit_before_message:
|
||||||
return
|
return
|
||||||
if self.commit_before_message[-1] != self.repo.get_head_sha():
|
if self.commit_before_message[-1] != self.repo.get_head_commit_sha():
|
||||||
self.io.tool_output("You can use /undo to undo and discard each aider commit.")
|
self.io.tool_output("You can use /undo to undo and discard each aider commit.")
|
||||||
|
|
||||||
def dirty_commit(self):
|
def dirty_commit(self):
|
||||||
|
|
|
@ -420,7 +420,7 @@ class Commands:
|
||||||
self.io.tool_error("No git repository found.")
|
self.io.tool_error("No git repository found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
last_commit = self.coder.repo.get_head()
|
last_commit = self.coder.repo.get_head_commit()
|
||||||
if last_commit and not last_commit.parents:
|
if last_commit and not last_commit.parents:
|
||||||
self.io.tool_error("This is the first commit in the repository. Cannot undo.")
|
self.io.tool_error("This is the first commit in the repository. Cannot undo.")
|
||||||
return
|
return
|
||||||
|
@ -461,8 +461,8 @@ class Commands:
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
|
|
||||||
last_commit_hash = self.coder.repo.get_head_sha(short=True)
|
last_commit_hash = self.coder.repo.get_head_commit_sha(short=True)
|
||||||
last_commit_message = self.coder.repo.get_head_message("(unknown)")
|
last_commit_message = self.coder.repo.get_head_commit_message("(unknown)")
|
||||||
|
|
||||||
if last_commit_hash not in self.coder.aider_commit_hashes:
|
if last_commit_hash not in self.coder.aider_commit_hashes:
|
||||||
self.io.tool_error("The last commit was not made by aider in this chat session.")
|
self.io.tool_error("The last commit was not made by aider in this chat session.")
|
||||||
|
@ -482,8 +482,8 @@ class Commands:
|
||||||
self.io.tool_output(f"Removed: {last_commit_hash} {last_commit_message}")
|
self.io.tool_output(f"Removed: {last_commit_hash} {last_commit_message}")
|
||||||
|
|
||||||
# Get the current HEAD after undo
|
# Get the current HEAD after undo
|
||||||
current_head_hash = self.coder.repo.get_head_sha(short=True)
|
current_head_hash = self.coder.repo.get_head_commit_sha(short=True)
|
||||||
current_head_message = self.coder.repo.get_head_message("(unknown)")
|
current_head_message = self.coder.repo.get_head_commit_message("(unknown)")
|
||||||
self.io.tool_output(f"Now at: {current_head_hash} {current_head_message}")
|
self.io.tool_output(f"Now at: {current_head_hash} {current_head_message}")
|
||||||
|
|
||||||
if self.coder.main_model.send_undo_reply:
|
if self.coder.main_model.send_undo_reply:
|
||||||
|
@ -495,7 +495,7 @@ class Commands:
|
||||||
self.io.tool_error("No git repository found.")
|
self.io.tool_error("No git repository found.")
|
||||||
return
|
return
|
||||||
|
|
||||||
current_head = self.coder.repo.get_head_sha()
|
current_head = self.coder.repo.get_head_commit_sha()
|
||||||
if current_head is None:
|
if current_head is None:
|
||||||
self.io.tool_error("Unable to get current commit. The repository might be empty.")
|
self.io.tool_error("Unable to get current commit. The repository might be empty.")
|
||||||
return
|
return
|
||||||
|
|
|
@ -138,7 +138,7 @@ class GitRepo:
|
||||||
os.environ["GIT_AUTHOR_NAME"] = committer_name
|
os.environ["GIT_AUTHOR_NAME"] = committer_name
|
||||||
|
|
||||||
self.repo.git.commit(cmd)
|
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)
|
self.io.tool_output(f"Commit {commit_hash} {commit_message}", bold=True)
|
||||||
|
|
||||||
# Restore the env
|
# Restore the env
|
||||||
|
@ -373,22 +373,22 @@ class GitRepo:
|
||||||
|
|
||||||
return self.repo.is_dirty(path=path)
|
return self.repo.is_dirty(path=path)
|
||||||
|
|
||||||
def get_head(self):
|
def get_head_commit(self):
|
||||||
try:
|
try:
|
||||||
return self.repo.head.commit
|
return self.repo.head.commit
|
||||||
except (ValueError, gitdb.exc.ODBError):
|
except (ValueError, gitdb.exc.ODBError):
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_head_sha(self, short=False):
|
def get_head_commit_sha(self, short=False):
|
||||||
commit = self.get_head()
|
commit = self.get_head_commit()
|
||||||
if not commit:
|
if not commit:
|
||||||
return
|
return
|
||||||
if short:
|
if short:
|
||||||
return commit.hexsha[:7]
|
return commit.hexsha[:7]
|
||||||
return commit.hexsha
|
return commit.hexsha
|
||||||
|
|
||||||
def get_head_message(self, default=None):
|
def get_head_commit_message(self, default=None):
|
||||||
commit = self.get_head()
|
commit = self.get_head_commit()
|
||||||
if not commit:
|
if not commit:
|
||||||
return default
|
return default
|
||||||
return commit.message
|
return commit.message
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue