Commit 2ff00e7d authored by ojan@chromium.org's avatar ojan@chromium.org

Cleanup model/ct-commit and use every.

-Get rid of url getter. There's no reason not to just
store the url as a regular property.
-Fix revision finder to not be blink specific.
-Don't split the whole message just to get the first line.
-Add tests. I had added tests in my last commit, but it
got lost somehow.
-Use every for computing revision ranges.

NOTRY=true

Review URL: https://codereview.chromium.org/406163003

git-svn-id: svn://svn.chromium.org/blink/trunk@178622 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 098d00ad
<!--
Copyright 2014 The Chromium Authors. All rights reserved.
Use of this source code is governed by a BSD-style license that can be
found in the LICENSE file.
-->
<link rel="import" href="ct-commit.html">
<script>
(function () {
module("ct-commit");
test("basic", 5, function() {
var message =
"This matches Gecko's behavior for these types of properties.\n" +
"\n" +
"BUG=17325\n" +
"R=jochen@chromium.org\n" +
"CC=abarth@chromium.org\n" +
"\n" +
"Review URL: https://chromiumcodereview.appspot.com/25022002\n" +
"\n" +
"git-svn-id: svn://svn.chromium.org/chrome/trunk@158545 bbb929c8-8fbe-4397-9dbb-9b2b20218538";
var urlBase = "http://mockbase.com";
var author = "mkwst@chromium.org";
var commit = new CTCommit(author, message, urlBase);
equal(commit.author, author);
equal(commit.message, message);
equal(commit.revision, 158545);
equal(commit.summary, "This matches Gecko's behavior for these types of properties.");
equal(commit.url, urlBase + "?view=rev&revision=158545");
});
test("blink", 2, function() {
var message =
"This matches Gecko's behavior for these types of properties.\n" +
"\n" +
"BUG=17325\n" +
"R=jochen@chromium.org\n" +
"CC=abarth@chromium.org\n" +
"\n" +
"Review URL: https://chromiumcodereview.appspot.com/25022002\n" +
"\n" +
"git-svn-id: svn://svn.chromium.org/blink/trunk@158545 bbb929c8-8fbe-4397-9dbb-9b2b20218538";
var urlBase = "http://mockbase.com";
var author = "mkwst@chromium.org";
var commit = new CTCommit(author, message, urlBase);
equal(commit.revision, 158545);
equal(commit.url, urlBase + "?view=rev&revision=158545");
});
})();
</script>
......@@ -9,26 +9,29 @@ function CTCommit(author, message, baseUrl) {
this.author = author;
this.message = message;
this.revision = this._findRevision();
// FIXME: This is a needlessly expensive way to grab the first line.
this.summary = this.message.split('\n')[0];
this._baseUrl = baseUrl;
this.summary = this._findSummary();
this.url = this._url(baseUrl);
}
Object.defineProperty(CTCommit.prototype, "url", {
get: function url() {
return this._baseUrl + '?' + Object.toQueryString({
view: 'rev',
revision: this.revision,
});
},
});
CTCommit.prototype._url = function(baseUrl) {
return baseUrl + '?' + Object.toQueryString({
view: 'rev',
revision: this.revision,
});
}
CTCommit.prototype._findRevision = function() {
// FIXME: Make this regexp more general.
var regexp = /git-svn-id: svn:\/\/svn.chromium.org\/blink\/trunk@(\d+)/;
// FIXME: This needs to be updated post git-migration to
// use the new commit numbers (ideally not git hashes!).
var regexp = /git-svn-id:[^@]*@(\d+)/;
var match = regexp.exec(this.message);
if (match)
return parseInt(match[1], 10);
return null;
}
CTCommit.prototype._findSummary = function() {
var index = this.message.indexOf('\n');
return this.message.substring(0, index);
}
</script>
......@@ -56,6 +56,7 @@ THE POSSIBILITY OF SUCH DAMAGE.
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="polymer-load-warning.html">
<link rel="import" href="model/ct-commit-log-tests.html">
<link rel="import" href="model/ct-commit-tests.html">
<link rel="import" href="ui/ct-builder-grid-tests.html">
<link rel="import" href="ui/ct-builder-tests.html">
<link rel="import" href="ui/ct-commit-tests.html">
......
......@@ -34,10 +34,7 @@ found in the LICENSE file.
_update: function() {
if (!this.first || !this.last)
return;
this._revisions = [];
for (var i = this.first; i <= this.last; i++)
this._revisions.push(i);
this._revisions = Number.range(this.first, this.last).every();
},
});
</script>
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment