diff options
author | Adam Spiers <git@adamspiers.org> | 2015-01-11 23:01:08 +0000 |
---|---|---|
committer | Adam Spiers <git@adamspiers.org> | 2015-01-11 23:05:30 +0000 |
commit | 6e0c247e7e07b5c6732deedd194985da3e817007 (patch) | |
tree | d5b5c7c2484a7100627d2765892dd1ba93a4c397 | |
parent | c46d924bd01fd4cc571ebaeaceedb533e0988c2b (diff) | |
download | git-deps-6e0c247e7e07b5c6732deedd194985da3e817007.tar.gz |
show all refs in tip, not just what git describe finds
-rwxr-xr-x | git-deps | 14 | ||||
-rw-r--r-- | html/js/git-deps-graph.coffee | 7 |
2 files changed, 18 insertions, 3 deletions
@@ -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) |