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.commitLog = commitLog; |
12 if (group.failures && group.failures.first()) { | 12 this._revisions = revisions; |
13 this.firstFailing = group.failures.first().firstFailingRevisions; | |
14 this.lastPassing = group.failures.first().lastPassingRevisions; | |
15 } | |
16 this._updateRepositories(); | 13 this._updateRepositories(); |
17 } | 14 } |
18 | 15 |
19 CTCommitList.prototype._updateRepositories = function() { | 16 CTCommitList.prototype._updateRepositories = function() { |
20 this.repositories = []; | 17 this.repositories = []; |
21 if (!this.commitLog || !this.lastPassing || !this.firstFailing) | 18 if (!this.commitLog || !this._revisions.length) |
22 return; | 19 return; |
23 | 20 |
24 var allRepositories = this.commitLog._repositories.names; | 21 var allRepositories = this.commitLog._repositories.names; |
25 for (var i = 0; i < allRepositories.length; i++) { | 22 for (var i = 0; i < allRepositories.length; i++) { |
26 var repository = allRepositories[i]; | 23 var repository = allRepositories[i]; |
27 | 24 |
28 var commits = this._commits(repository); | 25 var commits = this._getCommitsForRepo(repository); |
29 if (!commits.length) | 26 if (!commits.length) |
30 continue; | 27 continue; |
31 | 28 |
32 this.repositories.push({ | 29 this.repositories.push({ |
33 name: repository, | 30 name: repository, |
34 range: this._range(commits), | 31 range: this._displayRange(commits, repository), |
35 commits: commits, | 32 commits: commits, |
36 expanded: false | 33 expanded: false |
37 }); | 34 }); |
38 } | 35 } |
39 }; | 36 }; |
40 | 37 |
41 CTCommitList.prototype._commits = function(repository) { | 38 CTCommitList.prototype._getCommitsForRepo = function(repository) { |
ojan
2014/08/23 01:23:05
Nit: What was wrong with the old name?
Mathieu
2014/08/24 23:42:10
As a new comer to the project it initially confuse
| |
42 var commits = []; | 39 return this.commitLog.range(repository, this._revisions); |
40 } | |
43 | 41 |
44 if (!this.firstFailing || !this.lastPassing) | 42 CTCommitList.prototype._displayRange = function(commits) { |
45 return []; | |
46 | |
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 }; | |
59 | |
60 CTCommitList.prototype._range = function(commits) { | |
61 return commits.first().revision + " : " + commits.last().revision; | 43 return commits.first().revision + " : " + commits.last().revision; |
62 }; | 44 }; |
63 | 45 |
64 </script> | 46 </script> |
OLD | NEW |