Title: [195993] trunk/Tools
Revision
195993
Author
[email protected]
Date
2016-02-01 16:55:34 -0800 (Mon, 01 Feb 2016)

Log Message

Add code to parse the git branches out of the Trac RSS feed https://bugs.webkit.org/show_bug.cgi?id=153624

Reviewed by Daniel Bates.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
(Trac.prototype.commitsOnBranch): Update filter to check for Git branches.
(Trac.prototype._convertCommitInfoElementToObject): Parse Git branches from the Trac RSS feed. Also changed "branchName" to
"branches" and updated the code to work with an array instead of a string.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js:
(MockTrac): Refactored example commits out into a constant, MockTrac.EXAMPLE_TRAC_COMMITS.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-git-trac-rss.xml: Added. Test
fixture that contains XML with a Git branch.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added unit test to test parsing Git
branches from Trac RSS feed. Also updated code to work with the new MockTrac.EXAMPLE_TRAC_COMMITS constant.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js (195992 => 195993)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js	2016-02-02 00:46:33 UTC (rev 195992)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js	2016-02-02 00:55:34 UTC (rev 195993)
@@ -65,8 +65,8 @@
 
     commitsOnBranch: function(branchName, filter)
     {
-        return this.recordedCommits.filter(function(commit) {
-            return (!commit.containsBranchLocation || commit.branchName === branchName) && filter(commit);
+        return this.recordedCommits.filter(function(commit, index, array) {
+            return (!commit.containsBranchLocation || commit.branches.includes(branchName)) && filter(commit, index, array);
         });
     },
 
@@ -142,7 +142,8 @@
             author: author,
             date: date,
             description: parsedDescription.innerHTML,
-            containsBranchLocation: location !== ""
+            containsBranchLocation: location !== "",
+            branches: []
         };
 
         if (result.containsBranchLocation) {
@@ -151,11 +152,11 @@
             if (location.startsWith("tags/"))
                 result.tag = location.substr(5, location.indexOf("/", 5) - 5);
             else if (location.startsWith("branches/"))
-                result.branchName = location.substr(9, location.indexOf("/", 9) - 9);
+                result.branches.push(location.substr(9, location.indexOf("/", 9) - 9));
             else if (location.startsWith("releases/"))
                 result.release = location.substr(9, location.indexOf("/", 9) - 9);
             else if (location.startsWith("trunk/"))
-                result.branchName = "trunk";
+                result.branches.push("trunk");
             else if (location.startsWith("submissions/"))
                 ; // These changes are never relevant to the dashboard.
             else {
@@ -165,6 +166,12 @@
             }
         }
 
+        var gitBranches = doc.evaluate("./branches", commitElement, null, XPathResult.STRING_TYPE).stringValue;
+        if (gitBranches) {
+            result.containsBranchLocation = true;
+            result.branches = result.branches.concat(gitBranches.split(", "));
+        }
+
         return result;
     },
 

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js (195992 => 195993)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js	2016-02-02 00:46:33 UTC (rev 195992)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js	2016-02-02 00:55:34 UTC (rev 195993)
@@ -26,58 +26,6 @@
 MockTrac = function()
 {
     Trac.call(this, "https://trac.webkit.org/");
-    this.recordedCommits = [
-        {
-            "revisionNumber": 33018,
-            "link": "https://trac.webkit.org/changeset/33018",
-            "title": { innerHTML: "commit message" },
-            "author": "[email protected]",
-            "date": new Date("2015-11-15T17:05:44.000Z"),
-            "description": "description",
-            "containsBranchLocation": true,
-            "branchName": "trunk"
-        },
-        {
-            "revisionNumber": 33019,
-            "link": "https://trac.webkit.org/changeset/33019",
-            "title": { innerHTML: "commit message" },
-            "author": "[email protected]",
-            "date": new Date("2015-11-16T01:18:23.000Z"),
-            "description": "description",
-            "containsBranchLocation": true,
-            "branchName": "someOtherBranch"
-        },
-        {
-            "revisionNumber": 33020,
-            "link": "https://trac.webkit.org/changeset/33020",
-            "title": { innerHTML: "commit message" },
-            "author": "[email protected]",
-            "date": new Date("2015-11-16T01:19:27.000Z"),
-            "description": "description",
-            "containsBranchLocation": true,
-            "branchName": "trunk"
-        },
-        {
-            "revisionNumber": 33021,
-            "link": "https://trac.webkit.org/changeset/33021",
-            "title": { innerHTML: "commit message" },
-            "author": "[email protected]",
-            "date": new Date("2015-11-16T01:20:58.000Z"),
-            "description": "description",
-            "containsBranchLocation": true,
-            "branchName": "someOtherBranch"
-        },
-        {
-            "revisionNumber": 33022,
-            "link": "https://trac.webkit.org/changeset/33022",
-            "title": { innerHTML: "commit message" },
-            "author": "[email protected]",
-            "date": new Date("2015-11-16T01:22:01.000Z"),
-            "description": "description",
-            "containsBranchLocation": true,
-            "branchName": "trunk"
-        }
-    ];
 };
 
 BaseObject.addConstructorFunctions(MockTrac);
@@ -100,3 +48,56 @@
     {
     },
 };
+
+MockTrac.EXAMPLE_TRAC_COMMITS = [
+    {
+        "revisionNumber": 33018,
+        "link": "https://trac.webkit.org/changeset/33018",
+        "title": { innerHTML: "commit message" },
+        "author": "[email protected]",
+        "date": new Date("2015-11-15T17:05:44.000Z"),
+        "description": "description",
+        "containsBranchLocation": true,
+        "branches": ["trunk"]
+    },
+    {
+        "revisionNumber": 33019,
+        "link": "https://trac.webkit.org/changeset/33019",
+        "title": { innerHTML: "commit message" },
+        "author": "[email protected]",
+        "date": new Date("2015-11-16T01:18:23.000Z"),
+        "description": "description",
+        "containsBranchLocation": true,
+        "branches": ["someOtherBranch"]
+    },
+    {
+        "revisionNumber": 33020,
+        "link": "https://trac.webkit.org/changeset/33020",
+        "title": { innerHTML: "commit message" },
+        "author": "[email protected]",
+        "date": new Date("2015-11-16T01:19:27.000Z"),
+        "description": "description",
+        "containsBranchLocation": true,
+        "branches": ["trunk"]
+    },
+    {
+        "revisionNumber": 33021,
+        "link": "https://trac.webkit.org/changeset/33021",
+        "title": { innerHTML: "commit message" },
+        "author": "[email protected]",
+        "date": new Date("2015-11-16T01:20:58.000Z"),
+        "description": "description",
+        "containsBranchLocation": true,
+        "branches": ["someOtherBranch"]
+    },
+    {
+        "revisionNumber": 33022,
+        "link": "https://trac.webkit.org/changeset/33022",
+        "title": { innerHTML: "commit message" },
+        "author": "[email protected]",
+        "date": new Date("2015-11-16T01:22:01.000Z"),
+        "description": "description",
+        "containsBranchLocation": true,
+        "branches": ["trunk"]
+    }
+];
\ No newline at end of file

Added: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-git-trac-rss.xml (0 => 195993)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-git-trac-rss.xml	                        (rev 0)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-git-trac-rss.xml	2016-02-02 00:55:34 UTC (rev 195993)
@@ -0,0 +1,75 @@
+<?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>
+      <branches>master, someOtherBranch</branches>
+
+        <author>[email protected]</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>
+      <branches>master</branches>
+
+        <author>[email protected]</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>[email protected]</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>

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js (195992 => 195993)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js	2016-02-02 00:46:33 UTC (rev 195992)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js	2016-02-02 00:55:34 UTC (rev 195993)
@@ -31,11 +31,11 @@
 
 test("_loaded", function()
 {
+    this.trac.recordedCommits = MockTrac.EXAMPLE_TRAC_COMMITS;
     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);
+    client._onload_ = function () {
+        this.trac._loaded(client.responseXML);
     }.bind(this);
     client.send();
     var commits = this.trac.recordedCommits;
@@ -47,6 +47,24 @@
     }
 });
 
+test("parse gitBranches", function()
+{
+    var client = new XMLHttpRequest();
+    client.open("GET", "test-fixture-git-trac-rss.xml", false);
+    client._onload_ = function () {
+        this.trac._loaded(client.responseXML);
+    }.bind(this);
+    client.send();
+    var commits = this.trac.recordedCommits;
+    strictEqual(commits.length, 3, "should have 3 commits");
+    strictEqual(commits[0].branches.length, 0, "should have no branches");
+    strictEqual(commits[1].branches.length, 1, "should have one branch");
+    strictEqual(commits[1].branches.includes("master"), true, "should contain branch master");
+    strictEqual(commits[2].branches.length, 2, "should have two branches");
+    strictEqual(commits[2].branches.includes("master"), true, "should contain branch master");
+    strictEqual(commits[2].branches.includes("someOtherBranch"), true, "should contain branch someOtherBranch");
+});
+
 test("_parseRevisionFromURL", function()
 {
     strictEqual(this.trac._parseRevisionFromURL("https://trac.webkit.org/changeset/190497"), "190497", "Subversion");
@@ -57,6 +75,7 @@
 module("BuildBotQueueView", {
     setup: function() {
         this.trac = new MockTrac();
+        this.trac.recordedCommits = MockTrac.EXAMPLE_TRAC_COMMITS;
         this.queue = new MockBuildbotQueue();
         this.trunkBranch = {
             name: "trunk",

Modified: trunk/Tools/ChangeLog (195992 => 195993)


--- trunk/Tools/ChangeLog	2016-02-02 00:46:33 UTC (rev 195992)
+++ trunk/Tools/ChangeLog	2016-02-02 00:55:34 UTC (rev 195993)
@@ -1,3 +1,21 @@
+2016-02-01  Jason Marcell  <[email protected]>
+
+        Add code to parse the git branches out of the Trac RSS feed
+        https://bugs.webkit.org/show_bug.cgi?id=153624
+
+        Reviewed by Daniel Bates.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
+        (Trac.prototype.commitsOnBranch): Update filter to check for Git branches.
+        (Trac.prototype._convertCommitInfoElementToObject): Parse Git branches from the Trac RSS feed. Also changed "branchName" to
+        "branches" and updated the code to work with an array instead of a string.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/MockTrac.js:
+        (MockTrac): Refactored example commits out into a constant, MockTrac.EXAMPLE_TRAC_COMMITS.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/test-fixture-git-trac-rss.xml: Added. Test
+        fixture that contains XML with a Git branch.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added unit test to test parsing Git
+        branches from Trac RSS feed. Also updated code to work with the new MockTrac.EXAMPLE_TRAC_COMMITS constant.
+
 2016-02-01  Brady Eidson  <[email protected]>
 
         Add command line flag to DRT to output the number of tests completed in server mode.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to