From 6e0c247e7e07b5c6732deedd194985da3e817007 Mon Sep 17 00:00:00 2001 From: Adam Spiers Date: Sun, 11 Jan 2015 23:01:08 +0000 Subject: show all refs in tip, not just what git describe finds --- git-deps | 14 ++++++++++++++ html/js/git-deps-graph.coffee | 7 ++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/git-deps b/git-deps index 3ff029d..c850a9d 100755 --- a/git-deps +++ b/git-deps @@ -171,6 +171,7 @@ class JSONDependencyListener(DependencyListener): 'sha1': sha1, 'name': GitUtils.abbreviate_sha1(sha1), 'describe': GitUtils.describe(sha1), + 'refs': GitUtils.refs_to(sha1, self.repo()), 'author_name': commit.author.name, 'author_mail': commit.author.email, 'author_time': commit.author.time, @@ -262,6 +263,19 @@ class GitUtils(object): # cls.logger.debug(out) return out + @classmethod + def refs_to(cls, sha1, repo): + """Returns all refs pointing to the given SHA1.""" + matching = [] + for refname in repo.listall_references(): + symref = repo.lookup_reference(refname) + dref = symref.resolve() + oid = dref.target + commit = repo.get(oid) + if commit.hex == sha1: + matching.append(symref.shorthand) + + return matching class InvalidCommitish(StandardError): def __init__(self, commitish): diff --git a/html/js/git-deps-graph.coffee b/html/js/git-deps-graph.coffee index dd66b78..f6edeb8 100644 --- a/html/js/git-deps-graph.coffee +++ b/html/js/git-deps-graph.coffee @@ -318,10 +318,11 @@ tip_html = (d) -> title = top.find("p.commit-title") title.text d.title - unless d.describe is "" + if d.refs title.append " " - describe = title.children().first() - describe.addClass("commit-describe commit-ref").text(d.describe) + refs = title.children().first() + refs.addClass("commit-describe commit-ref") \ + .text(d.refs.join(" ")) top.find("span.commit-author").text(d.author_name) date = new Date(d.author_time * 1000) -- cgit