Refactor logic for parsing Trac revisions into its own function and add logic for...
authorjmarcell@apple.com <jmarcell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 19:54:10 +0000 (19:54 +0000)
committerjmarcell@apple.com <jmarcell@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 27 Jan 2016 19:54:10 +0000 (19:54 +0000)
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.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@195679 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/tests.js
Tools/ChangeLog

index cd540a5..4703059 100644 (file)
@@ -87,17 +87,19 @@ Trac.prototype = {
             "&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)
         {
index b681e20..f4f00ee 100644 (file)
@@ -47,6 +47,13 @@ test("_loaded", function()
     }
 });
 
+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;
index a8cecf7..11bf4cd 100644 (file)
@@ -1,3 +1,17 @@
+2016-01-27  Jason Marcell  <jmarcell@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  <ap@apple.com>
 
         Remove Mavericks from the flakiness dashboard