Sort incoming commits via date instead of revision number.
authorjmarcell@apple.com <jmarcell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 07:43:50 +0000 (07:43 +0000)
committerjmarcell@apple.com <jmarcell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 07:43:50 +0000 (07:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=153467

Reviewed by Alexey Proskuryakov.

Future Trac instances may use Git or other revision control systems where we cannnot rely on the revision number
for sorting revisions. Instead we use the commit date to sort revisions chronologically.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
(Trac.prototype._loaded): Sort via date instead of revision number.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js:
(MockTrac): Fix up the mock data to look more like real-world data.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-trac-rss.xml: Added.
Fake RSS feed that adds three more commits.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added unit tests to test
Trac._loaded().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195658 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-trac-rss.xml [new file with mode: 0644]
Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js
Tools/ChangeLog

index 2f0a4f2..cd540a5 100644 (file)
@@ -195,7 +195,7 @@ Trac.prototype = {
         }
 
         if (newCommits.length)
-            this.recordedCommits = newCommits.concat(this.recordedCommits).sort(function(a, b) { return a.revisionNumber - b.revisionNumber; });
+            this.recordedCommits = newCommits.concat(this.recordedCommits).sort(function(a, b) { return a.date - b.date; });
 
         if (newCommits.length || knownCommitsWereUpdated)
             this.dispatchEventToListeners(Trac.Event.CommitsUpdated, null);
index d0515e0..204bd47 100644 (file)
@@ -29,50 +29,50 @@ MockTrac = function()
     this.recordedCommits = [
         {
             "revisionNumber": 33018,
-            "link": "http://trac.webkit.org/repository/changeset/77018/safari",
-            "title": {},
-            "author": "John",
-            "date": "2015-11-15T17:05:44.000Z",
+            "link": "https://trac.webkit.org/changeset/33018",
+            "title": { innerHTML: "commit message" },
+            "author": "john@webkit.org",
+            "date": new Date("2015-11-15T17:05:44.000Z"),
             "description": "description",
             "containsBranchLocation": true,
             "branchName": "trunk"
         },
         {
             "revisionNumber": 33019,
-            "link": "http://trac.webkit.org/repository/changeset/77019/safari",
-            "title": {},
-            "author": "Paul",
-            "date": "2015-11-16T01:18:23.000Z",
+            "link": "https://trac.webkit.org/changeset/33019",
+            "title": { innerHTML: "commit message" },
+            "author": "paul@webkit.org",
+            "date": new Date("2015-11-16T01:18:23.000Z"),
             "description": "description",
             "containsBranchLocation": true,
             "branchName": "trunk"
         },
         {
             "revisionNumber": 33020,
-            "link": "http://trac.webkit.org/repository/changeset/77020/safari",
-            "title": {},
-            "author": "George",
-            "date": "2015-11-16T01:19:27.000Z",
+            "link": "https://trac.webkit.org/changeset/33020",
+            "title": { innerHTML: "commit message" },
+            "author": "george@webkit.org",
+            "date": new Date("2015-11-16T01:19:27.000Z"),
             "description": "description",
             "containsBranchLocation": true,
             "branchName": "trunk"
         },
         {
             "revisionNumber": 33021,
-            "link": "http://trac.webkit.org/repository/changeset/77021/safari",
-            "title": {},
-            "author": "Ringo",
-            "date": "2015-11-16T01:20:58.000Z",
+            "link": "https://trac.webkit.org/changeset/33021",
+            "title": { innerHTML: "commit message" },
+            "author": "ringo@webkit.org",
+            "date": new Date("2015-11-16T01:20:58.000Z"),
             "description": "description",
             "containsBranchLocation": true,
             "branchName": "someOtherBranch"
         },
         {
             "revisionNumber": 33022,
-            "link": "http://trac.webkit.org/repository/changeset/77022/safari",
-            "title": {},
-            "author": "Bob",
-            "date": "2015-11-16T01:22:01.000Z",
+            "link": "https://trac.webkit.org/changeset/33022",
+            "title": { innerHTML: "commit message" },
+            "author": "bob@webkit.org",
+            "date": new Date("2015-11-16T01:22:01.000Z"),
             "description": "description",
             "containsBranchLocation": true,
             "branchName": "trunk"
diff --git a/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-trac-rss.xml b/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-trac-rss.xml
new file mode 100644 (file)
index 0000000..74d6959
--- /dev/null
@@ -0,0 +1,71 @@
+<?xml version="1.0"?>
+<!--
+Copyright (C) 2016 Apple, Inc. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+1. Redistributions of source code must retain the above copyright
+   notice, this list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright
+   notice, this list of conditions and the following disclaimer in the
+   documentation and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGE.
+-->
+
+<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
+  <channel>
+    <title>WebKit</title>
+    <link>https://trac.webkit.org/timeline</link>
+    <description>Trac Timeline</description>
+    <language>en-US</language>
+    <generator>Trac 0.12.3</generator>
+    <image>
+      <title>WebKit</title>
+      <url>https://trac.webkit.org/chrome/site/favicon.png</url>
+      <link>https://trac.webkit.org/timeline</link>
+    </image>
+    <item>
+      <title>Changeset [33025]: Ita prorsus inquam Ad corpus diceres pertinere, sed ea, quae dixi</title>
+      
+        <author>george@webkit.org</author>
+
+      <pubDate>Tue, 26 Jan 2016 22:48:15 GMT</pubDate>
+      <link>https://trac.webkit.org/changeset/33025</link>
+      <guid isPermaLink="false">https://trac.webkit.org/changeset/33025/1453848495332569</guid>
+      <description>Description</description>
+      <category>changeset</category>
+    </item><item>
+      <title>Changeset [33024]: An eum discere ea mavis, quae cum plane perdidiceriti nihil sciat</title>
+      
+        <author>paul@webkit.org</author>
+
+      <pubDate>Tue, 26 Jan 2016 22:22:25 GMT</pubDate>
+      <link>https://trac.webkit.org/changeset/33024</link>
+      <guid isPermaLink="false">https://trac.webkit.org/changeset/33024/1453846945244007</guid>
+      <description>Description</description>
+      <category>changeset</category>
+    </item><item>
+      <title>Changeset [33023]: Lorem ipsum dolor sit amet, consectetur adipiscing elit.</title>
+      
+        <author>john@webkit.org</author>
+
+      <pubDate>Tue, 26 Jan 2016 22:22:14 GMT</pubDate>
+      <link>https://trac.webkit.org/changeset/33023</link>
+      <guid isPermaLink="false">https://trac.webkit.org/changeset/33023/1453846934034550</guid>
+      <description>Description</description>
+      <category>changeset</category>
+    </item>
+   </channel>
+</rss>
\ No newline at end of file
index 4a68313..b681e20 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
+module("Trac", {
+    setup: function() {
+        this.trac = new MockTrac();
+    }
+});
+
+test("_loaded", function()
+{
+    var client = new XMLHttpRequest();
+    client.open('GET', 'test-fixture-trac-rss.xml', false);
+    client.onreadystatechange = function () {
+        if (client.readyState === client.DONE)
+            this.trac._loaded(client.responseXML);
+    }.bind(this);
+    client.send();
+    var commits = this.trac.recordedCommits;
+    strictEqual(commits.length, 8, "should have 8 commits");
+    for (var i = 1; i < commits.length; i++) {
+        var firstRevision = commits[i - 1].revisionNumber;
+        var secondRevision = commits[i].revisionNumber;
+        strictEqual(secondRevision - firstRevision, 1, "commits should be in order " + firstRevision + ", " + secondRevision);
+    }
+});
+
 module("BuildBotQueueView");
 
 var settings = new Settings;
index 1a2a13b..ce0b756 100644 (file)
@@ -1,3 +1,22 @@
+2016-01-26  Jason Marcell  <jmarcell@apple.com>
+
+        Sort incoming commits via date instead of revision number.
+        https://bugs.webkit.org/show_bug.cgi?id=153467
+
+        Reviewed by Alexey Proskuryakov.
+
+        Future Trac instances may use Git or other revision control systems where we cannnot rely on the revision number
+        for sorting revisions. Instead we use the commit date to sort revisions chronologically.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
+        (Trac.prototype._loaded): Sort via date instead of revision number.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js:
+        (MockTrac): Fix up the mock data to look more like real-world data.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-trac-rss.xml: Added.
+        Fake RSS feed that adds three more commits.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added unit tests to test
+        Trac._loaded().
+
 2016-01-26  I-Ting Liu  <iting_liu@apple.com>
 
         Add a test for WebKit::stringMatchesWildcardString.