OLD | NEW |
---|---|
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="ct-commit-log.html"> | 7 <link rel="import" href="ct-commit-log.html"> |
8 | 8 |
9 <script> | 9 <script> |
10 function CTCommitList(group, commits) { | 10 function CTCommitList(commitLog, revisions) { |
11 this.commitLog = commits; | 11 this._initRevisions(revisions); |
12 if (group.failures && group.failures.first()) { | 12 this.update(commitLog); |
13 this.firstFailing = group.failures.first().firstFailingRevisions; | |
14 this.lastPassing = group.failures.first().lastPassingRevisions; | |
15 } | |
16 this._updateRepositories(); | |
17 } | 13 } |
18 | 14 |
19 CTCommitList.prototype._updateRepositories = function() { | 15 CTCommitList.prototype.update = function(commitLog) { |
20 this.repositories = []; | 16 this.repositories = []; |
21 if (!this.commitLog || !this.lastPassing || !this.firstFailing) | 17 if (!commitLog) |
22 return; | 18 return; |
23 | 19 |
24 var allRepositories = this.commitLog._repositories.names; | 20 var allRepositories = commitLog._repositories.names; |
25 for (var i = 0; i < allRepositories.length; i++) { | 21 for (var i = 0; i < allRepositories.length; i++) { |
26 var repository = allRepositories[i]; | 22 var repository = allRepositories[i]; |
23 if (!this.revisions[repository]) | |
24 continue; | |
27 | 25 |
28 var commits = this._commits(repository); | 26 var commits = commitLog.range(repository, this.revisions[repository]); |
29 if (!commits.length) | 27 if (!commits.length) |
30 continue; | 28 continue; |
31 | 29 |
32 this.repositories.push({ | 30 this.repositories.push({ |
33 name: repository, | 31 name: repository, |
34 range: this._range(commits), | 32 range: this._displayRange(commits, repository), |
35 commits: commits, | 33 commits: commits, |
36 expanded: false | 34 expanded: false |
37 }); | 35 }); |
38 } | 36 } |
39 }; | 37 }; |
40 | 38 |
41 CTCommitList.prototype._commits = function(repository) { | 39 CTCommitList.prototype._initRevisions = function(repoRevisions) { |
42 var commits = []; | 40 this.revisions = {}; |
41 repoRevisions.forEach(function(repoRevision) { | |
42 var split = repoRevision.split(':'); | |
43 var repo = split[0]; | |
44 var revision = parseInt(split[1], 10); | |
45 if (revision && repo) { | |
46 if (!this.revisions[repo]) { | |
47 this.revisions[repo] = [revision]; | |
48 } else { | |
49 this.revisions[repo].push(revision); | |
50 } | |
51 } | |
52 }.bind(this)); | |
43 | 53 |
44 if (!this.firstFailing || !this.lastPassing) | 54 Object.keys(this.revisions, function(repo) { |
45 return []; | 55 this.revisions[repo].sort(); |
ojan
2014/08/26 22:39:25
Why are these not already sorted since the thing w
Mathieu
2014/08/27 03:38:51
Done. You're right.
| |
46 | 56 }.bind(this)); |
47 var firstFailing = Number(this.firstFailing[repository]); | |
48 var lastPassing = Number(this.lastPassing[repository]); | |
49 if (firstFailing == lastPassing) | |
50 return commits; | |
51 | |
52 if (lastPassing > firstFailing) { | |
53 console.warn('Revision range is backwards, which is invalid:', lastPassing, firstFailing); | |
54 return commits; | |
55 } | |
56 | |
57 return this.commitLog.range(repository, lastPassing + 1, firstFailing); | |
58 }; | 57 }; |
59 | 58 |
60 CTCommitList.prototype._range = function(commits) { | 59 CTCommitList.prototype._displayRange = function(commits) { |
61 return commits.first().revision + " : " + commits.last().revision; | 60 return commits.first().revision + " : " + commits.last().revision; |
62 }; | 61 }; |
63 | 62 |
64 </script> | 63 </script> |
OLD | NEW |