aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xgit-deps30
-rw-r--r--html/test.json117
2 files changed, 129 insertions, 18 deletions
diff --git a/git-deps b/git-deps
index d92fb31..aa7dc1c 100755
--- a/git-deps
+++ b/git-deps
@@ -192,16 +192,30 @@ class JSONDependencyListener(DependencyListener):
# self.logger.debug(out)
return out
- def add_node(self, sha):
+ def add_node(self, commit):
"""Adds the node to the nodes array if it doesn't already exist, and
returns the node's index in the array."""
+ sha = commit.hex
abbrev = self.abbreviate_sha(sha)
if sha in self._nodes:
return self._nodes[sha]
+ title, separator, body = commit.message.partition("\n")
node = {
'name': abbrev,
'sha': sha,
'describe': self.describe(sha),
+ 'author_name': commit.author.name,
+ 'author_mail': commit.author.email,
+ 'author_time': commit.author.time,
+ 'author_offset': commit.author.offset,
+ 'committer_name': commit.committer.name,
+ 'committer_mail': commit.committer.email,
+ 'committer_time': commit.committer.time,
+ 'committer_offset': commit.committer.offset,
+ # 'message': commit.message,
+ 'title': title,
+ 'separator': separator,
+ 'body': body.lstrip("\n"),
}
self._json['nodes'].append(node)
self._nodes[sha] = len(self._json['nodes']) - 1
@@ -210,10 +224,7 @@ class JSONDependencyListener(DependencyListener):
def add_link(self, source, target):
self._json['links'].append
- def new_dependency(self, dependent, dependency, path, line_num):
- parent = dependent.hex
- child = dependency.hex
-
+ def new_dependency(self, parent, child, path, line_num):
source_index = self.add_node(parent)
target_index = self.add_node(child)
@@ -228,10 +239,11 @@ class JSONDependencyListener(DependencyListener):
self._json['links'].append(new_link)
- if parent in self._deps:
- self._deps[parent].append(child)
- else:
- self._deps[parent] = [child]
+ ph = parent.hex
+ ch = child.hex
+ if ph not in self._deps:
+ self._deps[ph] = []
+ self._deps[ph].append(ch)
def json(self):
for parent, children in self._deps.iteritems():
diff --git a/html/test.json b/html/test.json
index e3b18b4..90ee8f8 100644
--- a/html/test.json
+++ b/html/test.json
@@ -83,49 +83,148 @@
],
"nodes": [
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": 0,
+ "author_time": 1420486941,
+ "body": "This creates the JSON which will eventually be consumed by\nthe Javascript visualizer.\n",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420487137,
"describe": "tags/test-0",
"name": "2b6d591",
- "sha": "2b6d5915f6433b9eb1685751b82cfbebcbb37981"
+ "separator": "\n",
+ "sha": "2b6d5915f6433b9eb1685751b82cfbebcbb37981",
+ "title": "add JSON listener"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": -300,
+ "author_time": 1384447153,
+ "body": "Automatic git commit dependency inference tool.\n\nOriginally committed to:\n\n https://github.com/aspiers/git-config/blob/master/bin/git-deps\n\nand then split off into this repository via git filter-branch\nand other hackery, preserving history.\n",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420476874,
"describe": "",
"name": "b196757",
- "sha": "b1967573e81a8100a4cc778936de0ba0a8a8f5cb"
+ "separator": "\n",
+ "sha": "b1967573e81a8100a4cc778936de0ba0a8a8f5cb",
+ "title": "first prototype of git-deps"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": -300,
+ "author_time": 1384471712,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420477027,
"describe": "",
"name": "3a1dd42",
- "sha": "3a1dd42fd6114a634ba7cf037ce61e2aee76db73"
+ "separator": "\n",
+ "sha": "3a1dd42fd6114a634ba7cf037ce61e2aee76db73",
+ "title": "add logging and recursion"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": -300,
+ "author_time": 1384563102,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420477027,
"describe": "",
"name": "3374b84",
- "sha": "3374b8419a45d91d3c0631be11c8cf893b272217"
+ "separator": "\n",
+ "sha": "3374b8419a45d91d3c0631be11c8cf893b272217",
+ "title": "add listener classes"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": 0,
+ "author_time": 1420483579,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420483579,
"describe": "",
"name": "ff82dda",
- "sha": "ff82dda196947650bd497301e61b282753193564"
+ "separator": "\n",
+ "sha": "ff82dda196947650bd497301e61b282753193564",
+ "title": "fix a bunch of PEP8 issues"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": -300,
+ "author_time": 1384579026,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420477028,
"describe": "",
"name": "8d44254",
- "sha": "8d442544a20b706b996d66ab390a16fd97b48d6d"
+ "separator": "\n",
+ "sha": "8d442544a20b706b996d66ab390a16fd97b48d6d",
+ "title": "use new-style classes"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": -300,
+ "author_time": 1384452615,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420477027,
"describe": "",
"name": "b144bfd",
- "sha": "b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5"
+ "separator": "\n",
+ "sha": "b144bfd5feb327ef7ce0c26bbfb6f4da573abfe5",
+ "title": "refactor into new DependencyDetector class"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": 0,
+ "author_time": 1420482533,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420482533,
"describe": "",
"name": "e406002",
- "sha": "e40600230d1c3059485437bd4d5690d61c9edb2f"
+ "separator": "\n",
+ "sha": "e40600230d1c3059485437bd4d5690d61c9edb2f",
+ "title": "don't show \"[False]\" default for boolean options"
},
{
+ "author_mail": "git@adamspiers.org",
+ "author_name": "Adam Spiers",
+ "author_offset": -300,
+ "author_time": 1384650040,
+ "body": "",
+ "committer_mail": "git@adamspiers.org",
+ "committer_name": "Adam Spiers",
+ "committer_offset": 0,
+ "committer_time": 1420477028,
"describe": "",
"name": "4f27a1e",
- "sha": "4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2"
+ "separator": "\n",
+ "sha": "4f27a1ee2b5fd63a58311a20e2aed0a24eda8da2",
+ "title": "add --exclude-commits"
}
]
}