| 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.html'> | 7 <link rel='import' href='ct-commit.html'> |
| 8 | 8 |
| 9 <link rel='import' href='ct-repositories.html'> |
| 10 |
| 9 <script> | 11 <script> |
| 10 function CTCommitLog() { | 12 function CTCommitLog() { |
| 11 // FIXME: This should be a map of repo-name to revision log using the same | |
| 12 // repo names that auto-sheriff.appspot's json uses. | |
| 13 | |
| 14 // FIXME: Use better feeds. | |
| 15 // https://chromium.googlesource.com/chromium/blink/+log/master?format=json | |
| 16 // https://chromium.googlesource.com/chromium/chromium/+log/master?format=json | |
| 17 // https://code.google.com/feeds/p/skia/svnchanges/basic | |
| 18 // https://code.google.com/feeds/p/v8/svnchanges/basic | |
| 19 // https://code.google.com/feeds/p/nativeclient/svnchanges/basic | |
| 20 this.commits = {}; | 13 this.commits = {}; |
| 14 this.firstRevision = {}; |
| 15 this._repositories = new CTRepositories(); |
| 21 } | 16 } |
| 22 | 17 |
| 23 CTCommitLog.prototype.update = function() { | 18 CTCommitLog.prototype.update = function() { |
| 24 // FIXME: Turn net.js into net.html and import it at the top of this file. | 19 var requests = []; |
| 25 return net.xml('http://blink.lc/blink/atom').then(this._processXml.bind(this))
; | 20 Object.keys(this._repositories.repositories, (function(name, repository) { |
| 21 var responseHandler = this._handleResponse.bind(this, repository.repositoryU
rl, repository.name); |
| 22 // FIXME: Turn net.js into net.html and import it at the top of this file. |
| 23 requests.push(net.ajax({url: repository.dataUrl}).then(responseHandler)); |
| 24 }.bind(this))); |
| 25 return Promise.all(requests); |
| 26 } | 26 } |
| 27 | 27 |
| 28 CTCommitLog.prototype._processXml = function(xml) { | 28 CTCommitLog.prototype._handleResponse = function(repositoryUrl, repository, json
) { |
| 29 Array.prototype.forEach.call(xml.getElementsByTagName('entry'), function(logen
try) { | 29 if (!this.commits[repository]) |
| 30 var author = logentry.getElementsByTagName('author')[0].textContent.trim(); | 30 this.commits[repository] = {}; |
| 31 var message = logentry.getElementsByTagName('content')[0].textContent.trim()
; | 31 |
| 32 // FIXME: Handle base urls for different repos. | 32 // FIXME: Fix googlesource to not do this outdated JSON XSS mitigation. |
| 33 var commit = new CTCommit(author, message, 'http://src.chromium.org/viewvc/b
link'); | 33 json = json.substring(')]}\n'.length); |
| 34 this.commits[commit.revision] = commit; | 34 JSON.parse(json).log.forEach(function(entry) { |
| 35 var commit = CTCommit.create(entry.author.name, entry.message, repositoryUrl
, repository); |
| 36 this.commits[repository][commit.revision] = commit; |
| 35 }.bind(this)); | 37 }.bind(this)); |
| 38 |
| 39 this.firstRevision[repository] = Object.keys(this.commits[repository]).sort()[
0]; |
| 40 } |
| 41 |
| 42 CTCommitLog.prototype.range = function(repository, first, last) { |
| 43 var commits = []; |
| 44 for (var revision = first; revision <= last; revision++) { |
| 45 // Until we've seen a commit we have data for, fill in dummy data |
| 46 // so that we show something. Assume that we have the correct data |
| 47 // for all the commits after the first one we have data for. |
| 48 if (revision >= this.firstRevision[repository]) { |
| 49 var commit = this.commits[repository][revision]; |
| 50 if (commit) |
| 51 commits.push(commit); |
| 52 } else { |
| 53 var url = this._repositories.repositories[repository].repositoryUrl; |
| 54 commits.push(CTCommit.createIncomplete(url, revision, repository)); |
| 55 } |
| 56 } |
| 57 return commits; |
| 36 } | 58 } |
| 37 </script> | 59 </script> |
| OLD | NEW |