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 Sep 6, 2020
1 parent 3a51ab8 commit 9bbed4f
Showing 1 changed file with 23 additions and 0 deletions.
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
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)}
]

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"]:
print(feature, ": ", str(snapshot[feature]).strip())
print()

0 comments on commit 9bbed4f

Please sign in to comment.