Title: [195679] trunk/Tools
Revision
195679
Author
jmarc...@apple.com
Date
2016-01-27 11:54:10 -0800 (Wed, 27 Jan 2016)

Log Message

Refactor logic for parsing Trac revisions into its own function and add logic for parsing git hashes.
https://bugs.webkit.org/show_bug.cgi?id=153332

Reviewed by Alexey Proskuryakov.

* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
(Trac.prototype._xmlTimelineURL): Uses new function.
(Trac.prototype._parseRevisionFromURL): Added. Pulled out logic for parsing revisions from a URL. Also added
logic for parsing git hashes.
* BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added tests for
Trac._parseRevisionFromURL.

Modified Paths

Diff

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


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js	2016-01-27 19:11:22 UTC (rev 195678)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js	2016-01-27 19:54:10 UTC (rev 195679)
@@ -87,18 +87,20 @@
             "&daysback=" + ((toDay - fromDay) / 1000 / 60 / 60 / 24);
     },
 
-    _convertCommitInfoElementToObject: function(doc, commitElement)
+    _parseRevisionFromURL: function(url)
     {
-        var link = doc.evaluate("./link", commitElement, null, XPathResult.STRING_TYPE).stringValue;
-
         // There are multiple link formats for Trac that we support:
         // https://trac.webkit.org/changeset/190497
         // http://trac.foobar.com/repository/changeset/75388/project
-        var linkComponents = link.split("/");
-        var revisionNumber = parseInt(linkComponents.pop());
-        if (!revisionNumber)
-            var revisionNumber = parseInt(linkComponents.pop());
+        // https://git.foobar.com/trac/Whatever.git/changeset/0e498db5d8e5b5a342631
+        return /changeset\/([a-f0-9]+).*$/.exec(url)[1];
+    },
 
+    _convertCommitInfoElementToObject: function(doc, commitElement)
+    {
+        var link = doc.evaluate("./link", commitElement, null, XPathResult.STRING_TYPE).stringValue;
+        var revisionNumber = this._parseRevisionFromURL(link);
+
         function tracNSResolver(prefix)
         {
             if (prefix == "dc")

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


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js	2016-01-27 19:11:22 UTC (rev 195678)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js	2016-01-27 19:54:10 UTC (rev 195679)
@@ -47,6 +47,13 @@
     }
 });
 
+test("_parseRevisionFromURL", function()
+{
+    strictEqual(this.trac._parseRevisionFromURL("https://trac.webkit.org/changeset/190497"), "190497", "Subversion");
+    strictEqual(this.trac._parseRevisionFromURL("http://trac.foobar.com/repository/changeset/75388/project"), "75388", "Subversion with suffix");
+    strictEqual(this.trac._parseRevisionFromURL("https://git.foobar.com/trac/Whatever.git/changeset/0e498db5d8e5b5a342631"), "0e498db5d8e5b5a342631", "Git");
+});
+
 module("BuildBotQueueView");
 
 var settings = new Settings;

Modified: trunk/Tools/ChangeLog (195678 => 195679)


--- trunk/Tools/ChangeLog	2016-01-27 19:11:22 UTC (rev 195678)
+++ trunk/Tools/ChangeLog	2016-01-27 19:54:10 UTC (rev 195679)
@@ -1,3 +1,17 @@
+2016-01-27  Jason Marcell  <jmarc...@apple.com>
+
+        Refactor logic for parsing Trac revisions into its own function and add logic for parsing git hashes.
+        https://bugs.webkit.org/show_bug.cgi?id=153332
+
+        Reviewed by Alexey Proskuryakov.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:
+        (Trac.prototype._xmlTimelineURL): Uses new function.
+        (Trac.prototype._parseRevisionFromURL): Added. Pulled out logic for parsing revisions from a URL. Also added
+        logic for parsing git hashes.
+        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added tests for
+        Trac._parseRevisionFromURL.
+
 2016-01-27  Alexey Proskuryakov  <a...@apple.com>
 
         Remove Mavericks from the flakiness dashboard
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to