Skip to content
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions gitgud/skills/user_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,26 @@ def display_entry(index, human_name, code_name, indent):
code_name=item.name,
indent=indent
)


def amending_message(before_ref, after_ref, show_hashes=True, show_files=True, show_refs=True): # noqa: E501

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method doesn't let you show the branches as shown in #257

file_operator = operations.get_operator()
display_data = [
{"_name": "Before", "_commit": file_operator.repo.commit(before_ref)},
{"_name": "After", "_commit": file_operator.repo.commit(after_ref)}

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here, it might be worth it to do tuples or nested dictionaries. Using underscores is a bit weird here.

]

for snapshot in display_data:
commit = snapshot["_commit"]
snapshot["Message"] = commit.message
if show_hashes:
snapshot["Hash"] = commit.hexsha[:7]
if show_files:
files = file_operator.get_commit_content(commit)
snapshot["File"] = "Present" if files else "Missing"

for snapshot in display_data:
print(snapshot["_name"] + ":")
for feature in ["Hash", "Message", "File"]:
Comment thread
sahansk2 marked this conversation as resolved.
Outdated
print(feature, ": ", str(snapshot[feature]).strip())
print()