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