aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2015-01-11 23:01:08 +0000
committerAdam Spiers <git@adamspiers.org>2015-01-11 23:05:30 +0000
commit6e0c247e7e07b5c6732deedd194985da3e817007 (patch)
treed5b5c7c2484a7100627d2765892dd1ba93a4c397
parentc46d924bd01fd4cc571ebaeaceedb533e0988c2b (diff)
downloadgit-deps-6e0c247e7e07b5c6732deedd194985da3e817007.tar.gz
show all refs in tip, not just what git describe finds
-rwxr-xr-xgit-deps14
-rw-r--r--html/js/git-deps-graph.coffee7
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 " <span />"
- 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)