Title: [246847] trunk/Websites/perf.webkit.org
Revision
246847
Author
[email protected]
Date
2019-06-26 14:59:41 -0700 (Wed, 26 Jun 2019)

Log Message

commit api should not return 'AmbiguousRevisionPrefix' if there is an exact revision match
https://bugs.webkit.org/show_bug.cgi?id=199227

Reviewed by Ryosuke Niwa.

When prefix match is specified, api should check whether there is an exact match when multiple commits
match the prefix.

* public/include/commit-log-fetcher.php: Added the logic to check if there is an exact match when multiple matches are found.
* server-tests/api-commits-tests.js: Added an unit test.

Modified Paths

Diff

Modified: trunk/Websites/perf.webkit.org/ChangeLog (246846 => 246847)


--- trunk/Websites/perf.webkit.org/ChangeLog	2019-06-26 19:35:26 UTC (rev 246846)
+++ trunk/Websites/perf.webkit.org/ChangeLog	2019-06-26 21:59:41 UTC (rev 246847)
@@ -1,3 +1,16 @@
+2019-06-26  Dewei Zhu  <[email protected]>
+
+        commit api should not return 'AmbiguousRevisionPrefix' if there is an exact revision match
+        https://bugs.webkit.org/show_bug.cgi?id=199227
+
+        Reviewed by Ryosuke Niwa.
+
+        When prefix match is specified, api should check whether there is an exact match when multiple commits
+        match the prefix.
+
+        * public/include/commit-log-fetcher.php: Added the logic to check if there is an exact match when multiple matches are found.
+        * server-tests/api-commits-tests.js: Added an unit test.
+
 2019-06-24  Dean Johnson  <[email protected]>
 
         [perf.webkit.org] Update summary page calculations to use mean instead of median

Modified: trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php (246846 => 246847)


--- trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php	2019-06-26 19:35:26 UTC (rev 246846)
+++ trunk/Websites/perf.webkit.org/public/include/commit-log-fetcher.php	2019-06-26 21:59:41 UTC (rev 246847)
@@ -201,11 +201,14 @@
     }
 
     private function commit_for_revision_prefix($repository_id, $revision_prefix) {
-        $rows = $this->db->query_and_fetch_all('SELECT * FROM commits WHERE commit_repository = $1 AND commit_revision LIKE $2 LIMIT 2', array($repository_id, Database::escape_for_like($revision_prefix) . '%'));
+        $rows = $this->db->query_and_fetch_all('SELECT * FROM commits WHERE commit_repository = $1 AND commit_revision LIKE $2 ORDER BY commit_revision LIMIT 2', array($repository_id, Database::escape_for_like($revision_prefix) . '%'));
         if (count($rows) == 0)
             exit_with_error('UnknownCommit', array('repository' => $repository_id, 'revision' => $revision_prefix));
-        if (count($rows) == 2)
+        if (count($rows) == 2) {
+            if ($rows[0]['commit_revision'] == $revision_prefix)
+                return $rows[0];
             exit_with_error('AmbiguousRevisionPrefix', array('repository' => $repository_id, 'revision' => $revision_prefix));
+        }
         return $rows[0];
     }
 

Modified: trunk/Websites/perf.webkit.org/server-tests/api-commits-tests.js (246846 => 246847)


--- trunk/Websites/perf.webkit.org/server-tests/api-commits-tests.js	2019-06-26 19:35:26 UTC (rev 246846)
+++ trunk/Websites/perf.webkit.org/server-tests/api-commits-tests.js	2019-06-26 21:59:41 UTC (rev 246847)
@@ -39,6 +39,27 @@
         ]
     }
 
+    const commitsOnePrefixOfTheOther = {
+        "slaveName": "someSlave",
+        "slavePassword": "somePassword",
+        "commits": [
+            {
+                "repository": "WebKit",
+                "revision": "21094",
+                "time": "2017-01-20T02:52:34.577Z",
+                "author": {"name": "Zalan Bujtas", "account": "[email protected]"},
+                "message": "a message",
+            },
+            {
+                "repository": "WebKit",
+                "revision": "210949",
+                "time": "2017-01-20T03:23:50.645Z",
+                "author": {"name": "Chris Dumez", "account": "[email protected]"},
+                "message": "some message",
+            }
+        ]
+    }
+
     const systemVersionCommits = {
         "slaveName": "someSlave",
         "slavePassword": "somePassword",
@@ -460,6 +481,16 @@
             assert.equal(result['status'], 'AmbiguousRevisionPrefix');
         });
 
+        it("should not return 'AmbiguousRevisionPrefix' when there is a commit revision extract matches specified revision prefix", async () => {
+            const remote = TestServer.remoteAPI();
+            await addSlaveForReport(commitsOnePrefixOfTheOther);
+            await remote.postJSONWithStatus('/api/report-commits/', commitsOnePrefixOfTheOther);
+            const result = await remote.getJSON('/api/commits/WebKit/21094?prefix-match=true');
+            assert.equal(result['status'], 'OK');
+            assert.deepEqual(result['commits'].length, 1);
+            assertCommitIsSameAsOneSubmitted(result['commits'][0], commitsOnePrefixOfTheOther['commits'][0]);
+        });
+
         it("should return 'UnknownCommit' when no commit is found for a revision prefix", async () => {
             const remote = TestServer.remoteAPI();
             await addSlaveForReport(subversionCommits);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to