diff options
| author | 2018-11-17 08:15:28 +0000 | |
|---|---|---|
| committer | 2018-11-17 08:15:28 +0000 | |
| commit | e0a6ba39c613e13a3c07a7f09f66e3fa4d8490a6 (patch) | |
| tree | 41103be0a5916d6452ef4e69f4cbcbd849c3c669 | |
| parent | Add missing ")" (diff) | |
| signature | ||
show added/removed/modified counts as unique files when we're aggregating
commits
| -rw-r--r-- | modules/github.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/modules/github.py b/modules/github.py index 21731280..0881399f 100644 --- a/modules/github.py +++ b/modules/github.py @@ -78,6 +78,9 @@ class Module(ModuleManager.BaseModule): def _short_hash(self, hash): return hash[:8] + def _flat_unique(self, commits, key): + return set(itertools.chain(*(commit[key] for commit in commits))) + def push(self, event, full_name, data): outputs = [] if len(data["commits"]) <= 3: @@ -102,11 +105,12 @@ class Module(ModuleManager.BaseModule): pusher = data["pusher"]["name"] url = COMMIT_RANGE_URL % (full_name, first_id, last_id) - added = self._added(sum(len(c["added"]) for c in data["commits"])) - removed = self._removed( - sum(len(c["removed"]) for c in data["commits"])) - modified = self._modified( - sum(len(c["modified"]) for c in data["commits"])) + commits = data["commits"] + added = self._added(len(self._flat_unique(commits, "added"))) + removed = self._removed(len(self._flat_unique(commits, "removed"))) + modified = self._moddified(len(self._flat_unique(commits, + "modified"))) + outputs.append("(%s) [%s/%s/%s files] '%s' pushed %d commits - %s" % (full_name, added, removed, modified, pusher, len(data["commits"]), url)) |
