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