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() {} |
9 this.author = author; | 9 |
10 this.message = message; | 10 CTCommit.create = function(author, message, baseUrl, repository) { |
11 this.revision = this._findRevision(); | 11 var commit = new CTCommit(); |
12 this.summary = this._findSummary(); | 12 commit.author = author; |
13 this.url = this._url(baseUrl); | 13 commit.message = message; |
| 14 commit.revision = commit._findRevision(); |
| 15 commit.summary = commit._findSummary(); |
| 16 commit.url = commit._url(baseUrl); |
| 17 commit.repository = repository; |
| 18 return commit; |
| 19 } |
| 20 |
| 21 // This is for cases where we can't get the commit data off the |
| 22 // repository for some reason. |
| 23 CTCommit.createIncomplete = function(baseUrl, revision, repository) { |
| 24 var commit = new CTCommit(); |
| 25 commit.revision = revision; |
| 26 commit.url = commit._url(baseUrl); |
| 27 commit.repository = repository; |
| 28 return commit; |
14 } | 29 } |
15 | 30 |
16 CTCommit.prototype._url = function(baseUrl) { | 31 CTCommit.prototype._url = function(baseUrl) { |
17 return baseUrl + '?' + Object.toQueryString({ | 32 return baseUrl.assign({revision: this.revision}); |
18 view: 'rev', | |
19 revision: this.revision, | |
20 }); | |
21 } | 33 } |
22 | 34 |
23 CTCommit.prototype._findRevision = function() { | 35 CTCommit.prototype._findRevision = function() { |
24 // FIXME: This needs to be updated post git-migration to | 36 // FIXME: This needs to be updated post git-migration to |
25 // use the new commit numbers (ideally not git hashes!). | 37 // use the new commit numbers (ideally not git hashes!). |
26 var regexp = /git-svn-id:[^@]*@(\d+)/; | 38 var regexp = /git-svn-id:[^@]*@(\d+)/; |
27 var match = regexp.exec(this.message); | 39 var match = regexp.exec(this.message); |
28 if (match) | 40 if (match) |
29 return parseInt(match[1], 10); | 41 return parseInt(match[1], 10); |
30 return null; | 42 return null; |
31 } | 43 } |
32 | 44 |
33 CTCommit.prototype._findSummary = function() { | 45 CTCommit.prototype._findSummary = function() { |
34 var index = this.message.indexOf('\n'); | 46 var index = this.message.indexOf('\n'); |
35 return this.message.substring(0, index); | 47 return this.message.substring(0, index); |
36 } | 48 } |
37 </script> | 49 </script> |
OLD | NEW |