<!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>[277671] 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/277671">277671</a></dd>
<dt>Author</dt> <dd>zhifei_fang@apple.com</dd>
<dt>Date</dt> <dd>2021-05-18 12:56:03 -0700 (Tue, 18 May 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Commits updater should ignore null revision identifier
https://bugs.webkit.org/show_bug.cgi?id=225911

Reviewed by Ryosuke Niwa.

* public/include/commit-updater.php:
* server-tests/api-report-commits-tests.js:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebsitesperfwebkitorgChangeLog">trunk/Websites/perf.webkit.org/ChangeLog</a></li>
<li><a href="#trunkWebsitesperfwebkitorgpublicincludecommitupdaterphp">trunk/Websites/perf.webkit.org/public/include/commit-updater.php</a></li>
<li><a href="#trunkWebsitesperfwebkitorgservertestsapireportcommitstestsjs">trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.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 (277670 => 277671)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/ChangeLog 2021-05-18 19:52:05 UTC (rev 277670)
+++ trunk/Websites/perf.webkit.org/ChangeLog    2021-05-18 19:56:03 UTC (rev 277671)
</span><span class="lines">@@ -1,3 +1,13 @@
</span><ins>+2021-05-18  Zhifei Fang  <zhifei_fang@apple.com>
+
+        Commits updater should ignore null revision identifier
+        https://bugs.webkit.org/show_bug.cgi?id=225911
+
+        Reviewed by Ryosuke Niwa.
+
+        * public/include/commit-updater.php:
+        * server-tests/api-report-commits-tests.js:
+
</ins><span class="cx"> 2021-05-07  Zhifei Fang  <zhifei_fang@apple.com>
</span><span class="cx">         
</span><span class="cx">         Add support for syncing repo with commit revision label.
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgpublicincludecommitupdaterphp"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/public/include/commit-updater.php (277670 => 277671)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/public/include/commit-updater.php 2021-05-18 19:52:05 UTC (rev 277670)
+++ trunk/Websites/perf.webkit.org/public/include/commit-updater.php    2021-05-18 19:56:03 UTC (rev 277671)
</span><span class="lines">@@ -81,7 +81,7 @@
</span><span class="cx">             $has_update = count($commit_data) > 1;
</span><span class="cx"> 
</span><span class="cx">             $update = array('commit' => &$commit_data, 'repository' => &$commit_info['repository']);
</span><del>-            if (array_key_exists('revisionIdentifier', $commit_info)) {
</del><ins>+            if (array_key_exists('revisionIdentifier', $commit_info) && isset($commit_info['revisionIdentifier'])) {
</ins><span class="cx">                 if (array_key_exists($commit_info['revisionIdentifier'], $commit_revision_identifiers))
</span><span class="cx">                     $this->exit_with_error('DuplicatedRevisionIdentifier', array('commit' => $commit_info));
</span><span class="cx">                 $commit_revision_identifiers[$commit_info['revisionIdentifier']] = true;
</span><span class="lines">@@ -169,7 +169,7 @@
</span><span class="cx">             exit_with_error('InvalidAuthorFormat', array('commit' => $commit_info));
</span><span class="cx">         if (array_key_exists('previousCommit', $commit_info))
</span><span class="cx">             require_format('Revision', $commit_info['previousCommit'], '/^[A-Za-z0-9 \.]+$/');
</span><del>-        if (array_key_exists('revisionIdentifier', $commit_info))
</del><ins>+        if (array_key_exists('revisionIdentifier', $commit_info) && isset($commit_info['revisionIdentifier']))
</ins><span class="cx">             require_format('RevisionIdentifier', $commit_info['revisionIdentifier'], '/^\d+@[\w\.\-]+$/');
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebsitesperfwebkitorgservertestsapireportcommitstestsjs"></a>
<div class="modfile"><h4>Modified: trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js (277670 => 277671)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js  2021-05-18 19:52:05 UTC (rev 277670)
+++ trunk/Websites/perf.webkit.org/server-tests/api-report-commits-tests.js     2021-05-18 19:56:03 UTC (rev 277671)
</span><span class="lines">@@ -113,6 +113,93 @@
</span><span class="cx">         ]
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    const emptyRevisionIdentifierCommits = {
+        "workerName": "someWorker",
+        "workerPassword": "somePassword",
+        "commits": [
+            {
+                "repository": "WebKit",
+                "revision": "210948",
+                "revisionIdentifier": null,
+                "time": "2017-01-20T02:52:34.577Z",
+                "author": {"name": "Zalan Bujtas", "account": "zalan@apple.com"},
+                "message": "a message",
+            },
+            {
+                "repository": "WebKit",
+                "revision": "210949",
+                "previousCommit": "210948",
+                "revisionIdentifier": null,
+                "time": "2017-01-20T03:23:50.645Z",
+                "author": {"name": "Chris Dumez", "account": "cdumez@apple.com"},
+                "message": "some message",
+            },
+        ]
+    }
+
+    const emptyRevisionIdentifierAndValidRevisionIdentifierCommits = {
+        "workerName": "someWorker",
+        "workerPassword": "somePassword",
+        "commits": [
+            {
+                "repository": "WebKit",
+                "revision": "210948",
+                "revisionIdentifier": null,
+                "time": "2017-01-20T02:52:34.577Z",
+                "author": {"name": "Zalan Bujtas", "account": "zalan@apple.com"},
+                "message": "a message",
+            },
+            {
+                "repository": "WebKit",
+                "revision": "210949",
+                "previousCommit": "210948",
+                "revisionIdentifier": "184276@main",
+                "time": "2017-01-20T03:23:50.645Z",
+                "author": {"name": "Chris Dumez", "account": "cdumez@apple.com"},
+                "message": "some message",
+            },
+        ]
+    }
+
+    const emptyRevisionIdentifierWithInvalidRevisionIdentifierCommits = {
+        "workerName": "someWorker",
+        "workerPassword": "somePassword",
+        "commits": [
+            {
+                "repository": "WebKit",
+                "revision": "210948",
+                "revisionIdentifier": null,
+                "time": "2017-01-20T02:52:34.577Z",
+                "author": {"name": "Zalan Bujtas", "account": "zalan@apple.com"},
+                "message": "a message",
+            },
+            {
+                "repository": "WebKit",
+                "revision": "210949",
+                "revisionIdentifier": "",
+                "time": "2017-01-20T03:23:50.645Z",
+                "author": {"name": "Chris Dumez", "account": "cdumez@apple.com"},
+                "message": "some message",
+            },
+            {
+                "repository": "WebKit",
+                "revision": "210950",
+                "revisionIdentifier": false,
+                "time": "2017-01-20T03:23:50.645Z",
+                "author": {"name": "Chris Dumez", "account": "cdumez@apple.com"},
+                "message": "some message",
+            },
+            {
+                "repository": "WebKit",
+                "revision": "210950",
+                "revisionIdentifier": 0,
+                "time": "2017-01-20T03:23:50.645Z",
+                "author": {"name": "Chris Dumez", "account": "cdumez@apple.com"},
+                "message": "some message",
+            }
+        ]
+    }
+
</ins><span class="cx">     const invalidCommitRevisionIdentifierCommits = {
</span><span class="cx">         "workerName": "someWorker",
</span><span class="cx">         "workerPassword": "somePassword",
</span><span class="lines">@@ -197,8 +284,16 @@
</span><span class="cx">         });
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    it("should reject an invalid revision label", async () => {
</del><ins>+    it("should reject with invalid revision identifier with empty revision identifier", async () => {
</ins><span class="cx">         await addWorkerForReport(subversionCommit);
</span><ins>+        const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', emptyRevisionIdentifierWithInvalidRevisionIdentifierCommits);
+        assert.strictEqual(response['status'], 'InvalidRevisionIdentifier');
+        const rows = await TestServer.database().selectAll('commits');
+        assert.strictEqual(rows.length, 0);
+    });
+
+    it("should reject an invalid revision identifier", async () => {
+        await addWorkerForReport(subversionCommit);
</ins><span class="cx">         const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', invalidCommitRevisionIdentifierCommits);
</span><span class="cx">         assert.strictEqual(response['status'], 'InvalidRevisionIdentifier');
</span><span class="cx">         const rows = await TestServer.database().selectAll('commits');
</span><span class="lines">@@ -205,7 +300,7 @@
</span><span class="cx">         assert.strictEqual(rows.length, 0);
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    it("should reject with duplicated commit revision labels", async () => {
</del><ins>+    it("should reject with duplicated commit revision identifiers", async () => {
</ins><span class="cx">         await addWorkerForReport(subversionCommit);
</span><span class="cx">         const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', duplicatedCommitRevisionIdentifierCommits);
</span><span class="cx">         assert.strictEqual(response['status'], 'DuplicatedRevisionIdentifier');
</span><span class="lines">@@ -213,6 +308,73 @@
</span><span class="cx">         assert.strictEqual(rows.length, 0);
</span><span class="cx">     });
</span><span class="cx"> 
</span><ins>+    it("should store two commits with empty revision identifier", async () => {
+        await addWorkerForReport(emptyRevisionIdentifierCommits);
+        const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', emptyRevisionIdentifierCommits);
+        assert.strictEqual(response['status'], 'OK');
+        const db = TestServer.database();
+        const result = await Promise.all([db.selectAll('commits'), db.selectAll('committers')]);
+
+        const commits = result[0];
+        const committers = result[1];
+        assert.strictEqual(commits.length, 2);
+        assert.strictEqual(committers.length, 2);
+
+        let reportedData = emptyRevisionIdentifierCommits.commits[0];
+        assert.strictEqual(commits[0]['revision'], reportedData['revision']);
+        assert.strictEqual(commits[0]['revision_identifier'], null);
+        assert.strictEqual(commits[0]['time'].toString(), new Date('2017-01-20 02:52:34.577').toString());
+        assert.strictEqual(commits[0]['message'], reportedData['message']);
+        assert.strictEqual(commits[0]['committer'], committers[0]['id']);
+        assert.strictEqual(commits[0]['previous_commit'], null);
+        assert.strictEqual(committers[0]['name'], reportedData['author']['name']);
+        assert.strictEqual(committers[0]['account'], reportedData['author']['account']);
+
+        reportedData = emptyRevisionIdentifierCommits.commits[1];
+        assert.strictEqual(commits[1]['revision'], reportedData['revision']);
+        assert.strictEqual(commits[0]['revision_identifier'], null);
+        assert.strictEqual(commits[1]['time'].toString(), new Date('2017-01-20 03:23:50.645').toString());
+        assert.strictEqual(commits[1]['message'], reportedData['message']);
+        assert.strictEqual(commits[1]['committer'], committers[1]['id']);
+        assert.strictEqual(commits[1]['previous_commit'], commits[0]['id']);
+        assert.strictEqual(committers[1]['name'], reportedData['author']['name']);
+        assert.strictEqual(committers[1]['account'], reportedData['author']['account']);
+
+    });
+
+    it("should store two commits with one empty revision identifier and one valid revision identifier", async () => {
+        await addWorkerForReport(emptyRevisionIdentifierAndValidRevisionIdentifierCommits);
+        const response = await TestServer.remoteAPI().postJSON('/api/report-commits/', emptyRevisionIdentifierAndValidRevisionIdentifierCommits);
+        assert.strictEqual(response['status'], 'OK');
+        const db = TestServer.database();
+        const result = await Promise.all([db.selectAll('commits'), db.selectAll('committers')]);
+
+        const commits = result[0];
+        const committers = result[1];
+        assert.strictEqual(commits.length, 2);
+        assert.strictEqual(committers.length, 2);
+
+        let reportedData = emptyRevisionIdentifierAndValidRevisionIdentifierCommits.commits[0];
+        assert.strictEqual(commits[0]['revision'], reportedData['revision']);
+        assert.strictEqual(commits[0]['revision_identifier'], null);
+        assert.strictEqual(commits[0]['time'].toString(),  new Date('2017-01-20 02:52:34.577').toString());
+        assert.strictEqual(commits[0]['message'], reportedData['message']);
+        assert.strictEqual(commits[0]['committer'], committers[0]['id']);
+        assert.strictEqual(commits[0]['previous_commit'], null);
+        assert.strictEqual(committers[0]['name'], reportedData['author']['name']);
+        assert.strictEqual(committers[0]['account'], reportedData['author']['account']);
+
+        reportedData = emptyRevisionIdentifierAndValidRevisionIdentifierCommits.commits[1];
+        assert.strictEqual(commits[1]['revision'], reportedData['revision']);
+        assert.strictEqual(commits[1]['revision_identifier'], reportedData['revisionIdentifier']);
+        assert.strictEqual(commits[1]['time'].toString(),  new Date('2017-01-20 03:23:50.645').toString());
+        assert.strictEqual(commits[1]['message'], reportedData['message']);
+        assert.strictEqual(commits[1]['committer'], committers[1]['id']);
+        assert.strictEqual(commits[1]['previous_commit'], commits[0]['id']);
+        assert.strictEqual(committers[1]['name'], reportedData['author']['name']);
+        assert.strictEqual(committers[1]['account'], reportedData['author']['account']);
+    });
+
</ins><span class="cx">     it("should store two commits from a valid worker", () => {
</span><span class="cx">         return addWorkerForReport(subversionTwoCommits).then(() => {
</span><span class="cx">             return TestServer.remoteAPI().postJSON('/api/report-commits/', subversionTwoCommits);
</span><span class="lines">@@ -283,7 +445,7 @@
</span><span class="cx">         });
</span><span class="cx">     });
</span><span class="cx"> 
</span><del>-    it("should update an existing commit with commit label if there is one", async () => {
</del><ins>+    it("should update an existing commit with revision identifier if there is one", async () => {
</ins><span class="cx">         const db = TestServer.database();
</span><span class="cx">         const reportedData = subversionCommitWithRevisionIdentifier.commits[0];
</span><span class="cx">         await addWorkerForReport(subversionCommitWithRevisionIdentifier);
</span></span></pre>
</div>
</div>

</body>
</html>