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

Simple pagination added to git log pane #489

Open
wants to merge 1 commit 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
25 changes: 19 additions & 6 deletions git/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sublime
import sublime_plugin
from . import GitTextCommand, GitWindowCommand, plugin_file

MAX_LINES_LOG = 10

class GitBlameCommand(GitTextCommand):
def run(self, edit):
Expand Down Expand Up @@ -59,18 +59,27 @@ def run_log(self, follow, *args):
# the ASCII bell (\a) is just a convenient character I'm pretty sure
# won't ever come up in the subject of the commit (and if it does then
# you positively deserve broken output...)
# 9000 is a pretty arbitrarily chosen limit; picked entirely because
# it's about the size of the largest repo I've tested this on... and
# there's a definite hiccup when it's loading that
command = ['git', 'log', '--no-color', '--pretty=%s (%h)\a%an <%aE>\a%ad (%ar)',
'--date=local', '--max-count=9000', '--follow' if follow else None]
'--date=local', '--max-count={}'.format(MAX_LINES_LOG), '--follow' if follow else None]
command.extend(args)
self.run_command(
command,
self.log_done)

def continue_log(self, from_hash, follow, *args):
command = ['git', 'log', from_hash, '--no-color', '--pretty=%s (%h)\a%an <%aE>\a%ad (%ar)',
'--date=local', '--max-count=10', '--follow' if follow else None]
command.extend(args)
self.run_command(
command,
self.log_done)

def log_done(self, result):
self.results = [r.split('\a', 2) for r in result.strip().split('\n')]
if len(self.results) == MAX_LINES_LOG:
item = self.results[MAX_LINES_LOG - 1]
ref = item[0].split(' ')[-1].strip('()')
self.results.append( ["Continue from ({})".format(ref),"",""])
self.quick_panel(self.results, self.log_panel_done)

def log_panel_done(self, picked):
Expand All @@ -79,7 +88,11 @@ def log_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('()')
self.log_result(ref)
if item[0].split(' ')[0] == "Continue":
fn = self.get_file_name()
return self.continue_log(ref, fn != '', '--', fn)
else:
self.log_result(ref)

def log_result(self, ref):
# I'm not certain I should have the file name here; it restricts the
Expand Down