<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[210981] trunk/Websites/perf.webkit.org</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/210981">210981</a></dd>
<dt>Author</dt> <dd>rniwa@webkit.org</dd>
<dt>Date</dt> <dd>2017-01-20 14:02:09 -0800 (Fri, 20 Jan 2017)</dd>
</dl>
<h3>Log Message</h3>
<pre>REGRESSION(<a href="http://trac.webkit.org/projects/webkit/changeset/198234">r198234</a>): /api/commits/%revision% always fails
https://bugs.webkit.org/show_bug.cgi?id=167235
Reviewed by Antti Koivisto.
The bug was caused by a typo in CommitLogFetcher::fetch_revision, which was calling commit_for_revision on
$this->db instead of $this. This had been monkey-patched in the internal dashboard so it was working there.
Also fixed a bug that /latest wasn't doing what it claimed to do, and a bug that /oldest /latest,
and /last-reported would return a commit with all values set to null instead of an empty list.
Finally, added server API tests for /api/commits.
* public/api/commits.php:
(main): Add a comment for APIs that only exist for v2 UI.
* public/include/commit-log-fetcher.php:
(CommitLogFetcher::fetch_latest): Fixed the bug that this function was returning the oldest commit, not the
the latest commit as desired.
(CommitLogFetcher::fetch_revision): Fixed the bug that this function would always encounter an exception
because commit_for_revision is defined on $this, not $this->db.
(CommitLogFetcher::format_single_commit): Return an empty list instead of an array with a single commit with
all values set to null.
* server-tests/api-commits.js: Added. Added tests for the JSON API at /api/commits.
(.assertCommitIsSameAsOneSubmitted): Added. A helper function to compare a commit returned by /api/commits
to one sent to /api/report-commits.</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicapicommitsphp">trunk/Websites/perf.webkit.org/public/api/commits.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicincludecommitlogfetcherphp">trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php</a></li>
</ul>
<h3>Added Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgservertestsapicommitsjs">trunk/Websites/perf.webkit.org/server-tests/api-commits.js</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebsitesperfwebkitorgChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/ChangeLog (210980 => 210981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog        2017-01-20 21:50:26 UTC (rev 210980)
+++ trunk/Websites/perf.webkit.org/ChangeLog        2017-01-20 22:02:09 UTC (rev 210981)
</span><span class="lines">@@ -1,3 +1,33 @@
</span><ins>+2017-01-20 Ryosuke Niwa <rniwa@webkit.org>
+
+ REGRESSION(r198234): /api/commits/%revision% always fails
+ https://bugs.webkit.org/show_bug.cgi?id=167235
+
+ Reviewed by Antti Koivisto.
+
+ The bug was caused by a typo in CommitLogFetcher::fetch_revision, which was calling commit_for_revision on
+ $this->db instead of $this. This had been monkey-patched in the internal dashboard so it was working there.
+
+ Also fixed a bug that /latest wasn't doing what it claimed to do, and a bug that /oldest /latest,
+ and /last-reported would return a commit with all values set to null instead of an empty list.
+
+ Finally, added server API tests for /api/commits.
+
+ * public/api/commits.php:
+ (main): Add a comment for APIs that only exist for v2 UI.
+
+ * public/include/commit-log-fetcher.php:
+ (CommitLogFetcher::fetch_latest): Fixed the bug that this function was returning the oldest commit, not the
+ the latest commit as desired.
+ (CommitLogFetcher::fetch_revision): Fixed the bug that this function would always encounter an exception
+ because commit_for_revision is defined on $this, not $this->db.
+ (CommitLogFetcher::format_single_commit): Return an empty list instead of an array with a single commit with
+ all values set to null.
+
+ * server-tests/api-commits.js: Added. Added tests for the JSON API at /api/commits.
+ (.assertCommitIsSameAsOneSubmitted): Added. A helper function to compare a commit returned by /api/commits
+ to one sent to /api/report-commits.
+
</ins><span class="cx"> 2017-01-19 Ryosuke Niwa <rniwa@webkit.org>
</span><span class="cx">
</span><span class="cx"> measurement-sets API can incorrectly order points with OS version without commit time
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicapicommitsphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/api/commits.php (210980 => 210981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/api/commits.php        2017-01-20 21:50:26 UTC (rev 210980)
+++ trunk/Websites/perf.webkit.org/public/api/commits.php        2017-01-20 22:02:09 UTC (rev 210981)
</span><span class="lines">@@ -23,7 +23,7 @@
</span><span class="cx"> $filter = array_get($paths, 1);
</span><span class="cx"> $commits = array();
</span><span class="cx"> if (!$filter) {
</span><del>- $keyword = array_get($_GET, 'keyword');
</del><ins>+ $keyword = array_get($_GET, 'keyword'); // V2 UI compatibility.
</ins><span class="cx"> $from = array_get($_GET, 'from');
</span><span class="cx"> $to = array_get($_GET, 'to');
</span><span class="cx"> $commits = $fetcher->fetch_between($repository_id, $from, $to, $keyword);
</span><span class="lines">@@ -35,7 +35,7 @@
</span><span class="cx"> $commits = $fetcher->fetch_last_reported($repository_id);
</span><span class="cx"> } else if (ctype_alnum($filter)) {
</span><span class="cx"> $commits = $fetcher->fetch_revision($repository_id, $filter);
</span><del>- } else {
</del><ins>+ } else { // V2 UI compatibility.
</ins><span class="cx"> $matches = array();
</span><span class="cx"> if (!preg_match('/([A-Za-z0-9]+)[\:\-]([A-Za-z0-9]+)/', $filter, $matches))
</span><span class="cx"> exit_with_error('UnknownFilter', array('repositoryName' => $repository_name, 'filter' => $filter));
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicincludecommitlogfetcherphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php (210980 => 210981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php        2017-01-20 21:50:26 UTC (rev 210980)
+++ trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php        2017-01-20 22:02:09 UTC (rev 210981)
</span><span class="lines">@@ -88,7 +88,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function fetch_latest($repository_id) {
</span><del>- return $this->format_single_commit($this->db->select_first_row('commits', 'commit', array('repository' => $repository_id), 'time'));
</del><ins>+ return $this->format_single_commit($this->db->select_last_row('commits', 'commit', array('repository' => $repository_id), 'time'));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function fetch_last_reported($repository_id) {
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> function fetch_revision($repository_id, $revision) {
</span><del>- return $this->format_single_commit($this->db->commit_for_revision($repository_id, $revision));
</del><ins>+ return $this->format_single_commit($this->commit_for_revision($repository_id, $revision));
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private function commit_for_revision($repository_id, $revision) {
</span><span class="lines">@@ -111,6 +111,8 @@
</span><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> private function format_single_commit($commit_row) {
</span><ins>+ if (!$commit_row)
+ return array();
</ins><span class="cx"> $committer = $this->db->select_first_row('committers', 'committer', array('id' => $commit_row['commit_committer']));
</span><span class="cx"> return array($this->format_commit($commit_row, $committer));
</span><span class="cx"> }
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgservertestsapicommitsjs"></a>
<div class="addfile"><h4>Added: trunk/Websites/perf.webkit.org/server-tests/api-commits.js (0 => 210981)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/server-tests/api-commits.js         (rev 0)
+++ trunk/Websites/perf.webkit.org/server-tests/api-commits.js        2017-01-20 22:02:09 UTC (rev 210981)
</span><span class="lines">@@ -0,0 +1,334 @@
</span><ins>+'use strict';
+
+const assert = require('assert');
+
+const TestServer = require('./resources/test-server.js');
+const addSlaveForReport = require('./resources/common-operations.js').addSlaveForReport;
+const connectToDatabaseInEveryTest = require('./resources/common-operations.js').connectToDatabaseInEveryTest;
+
+describe("/api/commits/", () => {
+ TestServer.inject();
+ connectToDatabaseInEveryTest();
+
+ const subversionCommits = {
+ "slaveName": "someSlave",
+ "slavePassword": "somePassword",
+ "commits": [
+ {
+ "repository": "WebKit",
+ "revision": "210948",
+ "time": "2017-01-20T02:52:34.577Z",
+ "author": {"name": "Zalan Bujtas", "account": "zalan@apple.com"},
+ "message": "a message",
+ },
+ {
+ "repository": "WebKit",
+ "revision": "210949",
+ "time": "2017-01-20T03:23:50.645Z",
+ "author": {"name": "Chris Dumez", "account": "cdumez@apple.com"},
+ "message": "some message",
+ },
+ {
+ "repository": "WebKit",
+ "parent": "210949",
+ "revision": "210950",
+ "time": "2017-01-20T03:49:37.887Z",
+ "author": {"name": "Commit Queue", "account": "commit-queue@webkit.org"},
+ "message": "another message",
+ }
+ ]
+ }
+
+ const notYetReportedCommit = {
+ revision: '210951',
+ time: '2017-01-20T03:56:20.045Z'
+ }
+
+ function assertCommitIsSameAsOneSubmitted(commit, submitted)
+ {
+ assert.equal(commit['revision'], submitted['revision']);
+ assert.equal(new Date(commit['time']).toISOString(), submitted['time']);
+ assert.equal(commit['message'], submitted['message']);
+ assert.equal(commit['authorName'], submitted['author']['name']);
+ assert.equal(commit['authorEmail'], submitted['author']['account']);
+ }
+
+ describe('/api/commits/<repository>/', () => {
+ it("should return RepositoryNotFound when there are no matching repository", () => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit').then((response) => {
+ assert.equal(response['status'], 'RepositoryNotFound');
+ });
+ });
+
+ it("should return an empty result when there are no reported commits", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z'})
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit');
+ }).then((response) => {
+ assert.equal(response['status'], 'OK');
+ assert.deepEqual(response['commits'], []);
+ });
+ });
+
+ it("should return the list of all commits for a given repository", () => {
+ return addSlaveForReport(subversionCommits).then(() => {
+ return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionCommits);
+ }).then(function (response) {
+ assert.equal(response['status'], 'OK');
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/');
+ }).then(function (result) {
+ assert.equal(result['status'], 'OK');
+
+ const commits = result['commits'];
+ assert.equal(commits.length, 3);
+ const submittedCommits = subversionCommits['commits'];
+ assertCommitIsSameAsOneSubmitted(commits[0], submittedCommits[0]);
+ assertCommitIsSameAsOneSubmitted(commits[1], submittedCommits[1]);
+ assertCommitIsSameAsOneSubmitted(commits[2], submittedCommits[2]);
+ });
+ });
+ });
+
+ describe('/api/commits/<repository>/oldest', () => {
+ it("should return RepositoryNotFound when there are no matching repository", () => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/oldest').then((response) => {
+ assert.equal(response['status'], 'RepositoryNotFound');
+ });
+ });
+
+ it("should return an empty results when there are no commits", () => {
+ return TestServer.database().insert('repositories', {'id': 1, 'name': 'WebKit'}).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/oldest');
+ }).then((response) => {
+ assert.equal(response['status'], 'OK');
+ assert.deepEqual(response['commits'], []);
+ });
+ });
+
+ it("should return the oldest commit", () => {
+ const remote = TestServer.remoteAPI();
+ return addSlaveForReport(subversionCommits).then(() => {
+ return remote.postJSONWithStatus('/api/report-commits/', subversionCommits);
+ }).then(() => {
+ return remote.getJSON('/api/commits/WebKit/oldest');
+ }).then(function (result) {
+ assert.equal(result['status'], 'OK');
+ assert.equal(result['commits'].length, 1);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subversionCommits['commits'][0]);
+ });
+ });
+ });
+
+ describe('/api/commits/<repository>/latest', () => {
+ it("should return RepositoryNotFound when there are no matching repository", () => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/latest').then((response) => {
+ assert.equal(response['status'], 'RepositoryNotFound');
+ });
+ });
+
+ it("should return an empty results when there are no commits", () => {
+ return TestServer.database().insert('repositories', {'id': 1, 'name': 'WebKit'}).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/latest');
+ }).then((response) => {
+ assert.equal(response['status'], 'OK');
+ assert.deepEqual(response['commits'], []);
+ });
+ });
+
+ it("should return the oldest commit", () => {
+ const remote = TestServer.remoteAPI();
+ return addSlaveForReport(subversionCommits).then(() => {
+ return remote.postJSONWithStatus('/api/report-commits/', subversionCommits);
+ }).then(() => {
+ return remote.getJSON('/api/commits/WebKit/latest');
+ }).then(function (result) {
+ assert.equal(result['status'], 'OK');
+ assert.equal(result['commits'].length, 1);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subversionCommits['commits'].slice().pop());
+ });
+ });
+ });
+
+ describe('/api/commits/<repository>/last-reported', () => {
+ it("should return RepositoryNotFound when there are no matching repository", () => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/last-reported').then((response) => {
+ assert.equal(response['status'], 'RepositoryNotFound');
+ });
+ });
+
+ it("should return an empty result when there are no reported commits", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z'})
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/last-reported');
+ }).then((response) => {
+ assert.equal(response['status'], 'OK');
+ assert.deepEqual(response['commits'], []);
+ });
+ });
+
+ it("should return an empty results when there are no reported commits", () => {
+ return TestServer.database().insert('repositories', {'id': 1, 'name': 'WebKit'}).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/last-reported');
+ }).then((response) => {
+ assert.equal(response['status'], 'OK');
+ assert.deepEqual(response['commits'], []);
+ });
+ });
+
+ it("should return the oldest reported commit", () => {
+ const db = TestServer.database();
+ const remote = TestServer.remoteAPI();
+ return Promise.all([
+ addSlaveForReport(subversionCommits),
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': notYetReportedCommit.revision, 'time': notYetReportedCommit.time}),
+ ]).then(() => {
+ return remote.postJSONWithStatus('/api/report-commits/', subversionCommits);
+ }).then(() => {
+ return remote.getJSON('/api/commits/WebKit/last-reported');
+ }).then(function (result) {
+ assert.equal(result['status'], 'OK');
+ assert.equal(result['commits'].length, 1);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subversionCommits['commits'].slice().pop());
+ });
+ });
+ });
+
+ describe('/api/commits/<repository>/<commit>', () => {
+ it("should return RepositoryNotFound when there are no matching repository", () => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/210949').then((response) => {
+ assert.equal(response['status'], 'RepositoryNotFound');
+ });
+ });
+
+ it("should return UnknownCommit when one of the specified commit does not exist in the database", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z'})
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/210949');
+ }).then((response) => {
+ assert.equal(response['status'], 'UnknownCommit');
+ });
+ });
+
+ it("should return the commit even if it had not been reported", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z'})
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/210950');
+ }).then((result) => {
+ assert.equal(result['status'], 'OK');
+ assert.equal(result['commits'].length, 1);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], {
+ parent: null,
+ revision: '210950',
+ time: '2017-01-20T03:49:37.887Z',
+ author: {name: null, account: null},
+ message: null,
+ });
+ });
+ });
+
+ it("should return the full result for a reported commit", () => {
+ const remote = TestServer.remoteAPI();
+ return addSlaveForReport(subversionCommits).then(() => {
+ return remote.postJSONWithStatus('/api/report-commits/', subversionCommits);
+ }).then(() => {
+ return remote.getJSON('/api/commits/WebKit/210949');
+ }).then((result) => {
+ assert.equal(result['status'], 'OK');
+ assert.deepEqual(result['commits'].length, 1);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subversionCommits['commits'][1]);
+ });
+ });
+
+ });
+
+ describe('/api/commits/<repository>/?from=<commit-1>&to=<commit-2>', () => {
+ it("should return RepositoryNotFound when there are no matching repository", () => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/?from=210900&to=211000').then((response) => {
+ assert.equal(response['status'], 'RepositoryNotFound');
+ });
+ });
+
+ it("should return UnknownCommit when one of the specified commit does not exist in the database", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z'})
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/?from=210900&to=211000');
+ }).then((response) => {
+ assert.equal(response['status'], 'UnknownCommit');
+ });
+ });
+
+ it("should return an empty result when commits in the specified range have not reported", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210949', 'time': '2017-01-20T03:23:50.645Z'}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z'}),
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/?from=210949&to=210950');
+ }).then((response) => {
+ assert.equal(response['status'], 'OK');
+ assert.deepEqual(response['commits'], []);
+ });
+ });
+
+ it("should return reported commits in the specified range", () => {
+ const db = TestServer.database();
+ return Promise.all([
+ db.insert('repositories', {'id': 1, 'name': 'WebKit'}),
+ db.insert('commits', {'repository': 1, 'revision': '210949', 'time': '2017-01-20T03:23:50.645Z', 'reported': true}),
+ db.insert('commits', {'repository': 1, 'revision': '210950', 'time': '2017-01-20T03:49:37.887Z', 'reported': true}),
+ ]).then(() => {
+ return TestServer.remoteAPI().getJSON('/api/commits/WebKit/?from=210949&to=210950');
+ }).then((result) => {
+ assert.equal(result['status'], 'OK');
+ assert.deepEqual(result['commits'].length, 2);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], {
+ parent: null,
+ revision: '210949',
+ time: '2017-01-20T03:23:50.645Z',
+ author: {name: null, account: null},
+ message: null,
+ });
+ assertCommitIsSameAsOneSubmitted(result['commits'][1], {
+ parent: null,
+ revision: '210950',
+ time: '2017-01-20T03:49:37.887Z',
+ author: {name: null, account: null},
+ message: null,
+ });
+ });
+ });
+
+ it("should not include a revision not within the specified range", () => {
+ const remote = TestServer.remoteAPI();
+ return addSlaveForReport(subversionCommits).then(() => {
+ return remote.postJSONWithStatus('/api/report-commits/', subversionCommits);
+ }).then(() => {
+ return remote.getJSON('/api/commits/WebKit/?from=210948&to=210949');
+ }).then((result) => {
+ assert.equal(result['status'], 'OK');
+ assert.deepEqual(result['commits'].length, 2);
+ assertCommitIsSameAsOneSubmitted(result['commits'][0], subversionCommits['commits'][0]);
+ assertCommitIsSameAsOneSubmitted(result['commits'][1], subversionCommits['commits'][1]);
+ });
+ });
+
+ });
+
+});
</ins></span></pre>
</div>
</div>
</body>
</html>