Index: Tools/GardeningServer/model/ct-commit-list.html |
diff --git a/Tools/GardeningServer/model/ct-commit-list.html b/Tools/GardeningServer/model/ct-commit-list.html |
new file mode 100644 |
index 0000000000000000000000000000000000000000..4e14fea4d4e98776768ea9aad6e2536188f594be |
--- /dev/null |
+++ b/Tools/GardeningServer/model/ct-commit-list.html |
@@ -0,0 +1,59 @@ |
+<!-- |
+Copyright 2014 The Chromium Authors. All rights reserved. |
+Use of this source code is governed by a BSD-style license that can be |
+found in the LICENSE file. |
+--> |
+ |
+<link rel="import" href="ct-commit-log.html"> |
+ |
+<script> |
+function CTCommitList(group, commits) { |
+ this.revisionLog = commits; |
+ this.firstFailing = group.failures.first().firstFailingRevisions; |
+ this.lastPassing = group.failures.first().lastPassingRevisions; |
+} |
+ |
+CTCommitList.prototype.repositories = function() { |
+ var ret = []; |
+ if (!this.revisionLog || !this.lastPassing || !this.firstFailing) |
+ return ret; |
+ |
+ var allRepositories = Object.keys(this.revisionLog.commits).sort(); |
+ for (var i = 0; i < allRepositories.length; i++) { |
+ var repository = allRepositories[i]; |
+ |
+ var commits = this._commits(repository); |
+ if (commits.length == 0) |
ojan
2014/08/12 21:08:36
Nit: normally we just do "if (!commits.length)"
dsinclair
2014/08/15 14:05:04
Done.
|
+ continue; |
+ |
+ ret.push({ |
+ name: repository, |
+ range: this._range(commits), |
+ commits: commits |
+ }); |
+ } |
+ return ret; |
+}; |
+ |
+CTCommitList.prototype._commits = function(repository) { |
+ var commits = []; |
+ |
+ var firstFailing = Number(this.firstFailing[repository]); |
+ var lastPassing = Number(this.lastPassing[repository]); |
+ if (firstFailing == lastPassing) |
+ return commits; |
+ |
+ if (lastPassing > firstFailing) { |
+ console.warn('Revision range is backwards, which is invalid:', lastPassing, firstFailing); |
+ return commits; |
+ } |
+ |
+ return this.revisionLog.range(repository, lastPassing + 1, firstFailing); |
+}; |
+ |
+/* The existence of commits is a pre-condition to this method. */ |
ojan
2014/08/12 21:08:36
Nit: that's pretty clear from a glance at the code
dsinclair
2014/08/15 14:05:04
Done.
|
+CTCommitList.prototype._range = function(commits) { |
+ return commits.first().revision + " : " + commits.last().revision; |
+}; |
+ |
+</script> |