Skip to content

Commit

Permalink
Added amending status message
Browse files Browse the repository at this point in the history
  • Loading branch information
sahansk2 committed Aug 30, 2020
1 parent 5f86c26 commit 2fa1b4b
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions gitgud/skills/user_messages.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,28 @@ 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):
file_operator = operations.get_operator()
display_data = [
{"_snapshot": "Before", "_commit": file_operator.repo.commit(before_ref)},
{"_snapshot": "After", "_commit": file_operator.repo.commit(after_ref)}
]

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)
if files:
snapshot["File"] = "Present"
else:
snapshot["File"] = "Missing"

for snapshot in display_data:
print(snapshot["_snapshot"] + ":")
for feature in ["Hash", "Message", "File"]:
print(feature, ": ", str(snapshot[feature]).strip())
print()

0 comments on commit 2fa1b4b

Please sign in to comment.