Skip to content

Commit

Permalink
Merge 74178ab into 690e501
Browse files Browse the repository at this point in the history
  • Loading branch information
kaste committed Sep 24, 2019
2 parents 690e501 + 74178ab commit a64b97e
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 6 deletions.
7 changes: 4 additions & 3 deletions core/git_mixins/history.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
LogEntry = namedtuple("LogEntry", (
"short_hash",
"long_hash",
"ref",
"summary",
"raw_body",
"author",
Expand Down Expand Up @@ -37,7 +38,7 @@ def log(self, author=None, branch=None, file_path=None, start_end=None, cherry=N
"--max-count={}".format(limit) if limit else None,
"--skip={}".format(skip) if skip else None,
"--reverse" if reverse else None,
'--format=%h%n%H%n%s%n%an%n%ae%n%at%x00%B%x00%x00%n',
'--format=%h%n%H%n%D%n%s%n%an%n%ae%n%at%x00%B%x00%x00%n',
"--author={}".format(author) if author else None,
"--grep={}".format(msg_regexp) if msg_regexp else None,
"--cherry" if cherry else None,
Expand All @@ -62,8 +63,8 @@ def log(self, author=None, branch=None, file_path=None, start_end=None, cherry=N
continue
entry, raw_body = entry.split("\x00")

short_hash, long_hash, summary, author, email, datetime = entry.split("\n")
entries.append(LogEntry(short_hash, long_hash, summary, raw_body, author, email, datetime))
short_hash, long_hash, ref, summary, author, email, datetime = entry.split("\n")
entries.append(LogEntry(short_hash, long_hash, ref, summary, raw_body, author, email, datetime))

return entries

Expand Down
43 changes: 40 additions & 3 deletions core/ui_mixins/quick_panel.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from functools import partial
import itertools
import sublime
from ...common import util
Expand Down Expand Up @@ -498,12 +499,48 @@ def show_log_panel(entries, on_done, **kwargs):
return lp


def short_ref(ref):
def simplify(r):
if r.startswith('HEAD -> '):
return '{}*'.format(r[8:])

if r.startswith('tag: '):
return r[5:]

return r

def remote_diverged_from_local(refs, r):
try:
a, b = r.split('/', 1)
except ValueError:
return True
else:
return False if b in refs else True

if not ref:
return ''

refs = ref.split(', ')
refs = [simplify(r) for r in refs]
refs = [r for r in refs if remote_diverged_from_local(refs, r)]
refs = ["|{}|".format(r) for r in refs]

return ' '.join(refs)


filter_ = partial(filter, None)


class LogPanel(PaginatedPanel):

def format_item(self, entry):
return ([entry.short_hash + " " + entry.summary,
entry.author + ", " + util.dates.fuzzy(entry.datetime)],
entry.long_hash)
return (
[
" ".join(filter_((entry.short_hash, short_ref(entry.ref), entry.summary))),
", ".join(filter_((entry.author, util.dates.fuzzy(entry.datetime)))),
],
entry.long_hash
)

@property
def next_page_message(self):
Expand Down

0 comments on commit a64b97e

Please sign in to comment.