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 <script> | 7 <script> |
8 function CTCommit(author, message, baseUrl) { | 8 function CTCommit(author, message, baseUrl) { |
9 this.author = author; | 9 this.author = author; |
10 this.message = message; | 10 this.message = message; |
11 this.revision = this._findRevision(); | 11 this.revision = this._findRevision(); |
12 // FIXME: This is a needlessly expensive way to grab the first line. | 12 this.summary = this._findSummary(); |
13 this.summary = this.message.split('\n')[0]; | 13 this.url = this._url(baseUrl); |
14 this._baseUrl = baseUrl; | |
15 } | 14 } |
16 | 15 |
17 Object.defineProperty(CTCommit.prototype, "url", { | 16 CTCommit.prototype._url = function(baseUrl) { |
18 get: function url() { | 17 return baseUrl + '?' + Object.toQueryString({ |
19 return this._baseUrl + '?' + Object.toQueryString({ | 18 view: 'rev', |
20 view: 'rev', | 19 revision: this.revision, |
21 revision: this.revision, | 20 }); |
22 }); | 21 } |
23 }, | |
24 }); | |
25 | 22 |
26 CTCommit.prototype._findRevision = function() { | 23 CTCommit.prototype._findRevision = function() { |
27 // FIXME: Make this regexp more general. | 24 // FIXME: This needs to be updated post git-migration to |
28 var regexp = /git-svn-id: svn:\/\/svn.chromium.org\/blink\/trunk@(\d+)/; | 25 // use the new commit numbers (ideally not git hashes!). |
| 26 var regexp = /git-svn-id:[^@]*@(\d+)/; |
29 var match = regexp.exec(this.message); | 27 var match = regexp.exec(this.message); |
30 if (match) | 28 if (match) |
31 return parseInt(match[1], 10); | 29 return parseInt(match[1], 10); |
32 return null; | 30 return null; |
33 } | 31 } |
| 32 |
| 33 CTCommit.prototype._findSummary = function() { |
| 34 var index = this.message.indexOf('\n'); |
| 35 return this.message.substring(0, index); |
| 36 } |
34 </script> | 37 </script> |
OLD | NEW |