Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Tools / GardeningServer / model / ct-commit-list.html
1 <!--
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
4 found in the LICENSE file.
5 -->
6
7 <link rel="import" href="ct-commit-log.html">
8 <link rel="import" href="ct-repository-commit-list.html">
9
10 <script>
11 function CTCommitList(commitLog, revisions) {
12   this._initRevisions(revisions);
13   this.update(commitLog);
14 }
15
16 CTCommitList.prototype.update = function(commitLog) {
17   this.repositories = [];
18   if (!commitLog)
19     return;
20
21   var allRepositories = commitLog._repositories.names;
22   for (var i = 0; i < allRepositories.length; i++) {
23     var repository = allRepositories[i];
24     if (!this.revisions[repository])
25       continue;
26
27     var commits = commitLog.range(repository, this.revisions[repository]);
28     if (!commits.length)
29       continue;
30
31     this.repositories.push(new CTRepositoryCommitList(repository, commits));
32   }
33 };
34
35 CTCommitList.prototype._initRevisions = function(repoRevisions) {
36   this.revisions = {};
37   repoRevisions.forEach(function(repoRevision) {
38     var split = repoRevision.split(':');
39     var repo = split[0];
40     var revision = parseInt(split[1], 10);
41     if (revision && repo) {
42       if (!this.revisions[repo]) {
43         this.revisions[repo] = [revision];
44       } else {
45         this.revisions[repo].push(revision);
46       }
47     }
48   }.bind(this));
49 };
50
51 </script>