Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

history.GitLog.log_result: show full commit if no output #586

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
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
26 changes: 21 additions & 5 deletions git/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,17 @@ def log_result(self, ref):
# I'm not certain I should have the file name here; it restricts the
# details to just the current file. Depends on what the user expects...
# which I'm not sure of.
def check_if_output(result):
if result:
self.details_done(result)
else:
# If there's no output (file was likely renamed), then show the full commit.
self.run_command(
['git', 'log', '--no-color', '-p', '-1', ref],
self.details_done)
self.run_command(
['git', 'log', '--no-color', '-p', '-1', ref, '--', self.get_file_name()],
self.details_done)
check_if_output)

def details_done(self, result):
self.scratch(result, title="Git Commit Details",
Expand All @@ -112,7 +120,7 @@ def run(self, edit=None):
# GitLog Copy-Past
self.run_command(
['git', 'log', '--no-color', '--pretty=%s (%h)\a%an <%aE>\a%ad (%ar)',
'--date=local', '--max-count=9000', '--', self.get_file_name()],
'--date=local', '--follow', '--max-count=9000', '--', self.get_file_name()],
self.show_done)

def show_done(self, result):
Expand All @@ -126,10 +134,18 @@ def panel_done(self, picked):
item = self.results[picked]
# the commit hash is the last thing on the first line, in brackets
ref = item[0].split(' ')[-1].strip('()')

def use_name_at_ref(result):
p = result.strip().split('\n')[-1]
self.run_command(
['git', 'show', '%s:%s' % (ref, p)],
self.details_done,
ref=ref)

# In case of rename, before running `git show`, we need to get the path at that ref.
self.run_command(
['git', 'show', '%s:%s' % (ref, self.get_relative_file_path())],
self.details_done,
ref=ref)
['git', 'log', '--follow', '%s~1..HEAD' % ref, '--name-only', '--oneline', '--', self.get_relative_file_path()],
use_name_at_ref)

def details_done(self, result, ref):
syntax = self.view.settings().get('syntax')
Expand Down