Chromium Code Reviews| 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) { | 8 function CTCommit(author, message, baseUrl) { |
|
ojan
2014/07/21 00:44:56
I can split these changes out to a different patch
| |
| 9 this.author = author; | 9 this.author = author; |
| 10 this.message = message.trim(); | 10 this.message = message.trim(); |
| 11 this.revision = this._findRevision(); | 11 this.revision = this._findRevision(); |
| 12 this.summary = this.message.split('\n')[0]; | 12 this.summary = this.message.split('\n')[0]; |
| 13 this._baseUrl = baseUrl; | |
| 14 } | |
| 15 | |
| 16 CTCommit.prototype.url = function() { | |
|
abarth-chromium
2014/07/21 06:44:17
Getter?
ojan
2014/07/21 22:46:13
I really dislike getters. They make for surprising
| |
| 17 var queryParameters = { | |
| 18 view: 'rev', | |
| 19 revision: this.revision, | |
| 20 }; | |
| 21 return this._baseUrl + '?' + CTCommit._queryParam(queryParameters); | |
| 22 } | |
| 23 | |
| 24 // FIXME: This should live somewhere better so it can be reused. | |
| 25 CTCommit._queryParam = function(params) { | |
|
abarth-chromium
2014/07/21 06:44:17
Object.toQueryString from sugar
ojan
2014/07/21 22:46:13
Not sure how I missed that.
| |
| 26 var result = [] | |
| 27 Object.keys(params, function(key, value) { | |
| 28 result.push(encodeURIComponent(key) + '=' + encodeURIComponent(value)); | |
| 29 }); | |
| 30 return result.join('&'); | |
| 13 } | 31 } |
| 14 | 32 |
| 15 CTCommit.prototype._findRevision = function(message) { | 33 CTCommit.prototype._findRevision = function(message) { |
| 16 var regexp = /git-svn-id: svn:\/\/svn.chromium.org\/blink\/trunk@(\d+)/; | 34 var regexp = /git-svn-id: svn:\/\/svn.chromium.org\/blink\/trunk@(\d+)/; |
| 17 var match = regexp.exec(this.message); | 35 var match = regexp.exec(this.message); |
| 18 if (match) | 36 if (match) |
| 19 return parseInt(match[1], 10); | 37 return parseInt(match[1], 10); |
| 20 return null; | 38 return null; |
| 21 } | 39 } |
| 22 </script> | 40 </script> |
| OLD | NEW |