Changeset 211388 in webkit
- Timestamp:
- Jan 30, 2017 3:03:27 PM (7 years ago)
- Location:
- trunk/Tools
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js
r196402 r211388 31 31 32 32 this.baseURL = baseURL; 33 this._needsAuthentication = (typeof options === "object") && options[Trac.NeedsAuthentication] === true; 33 if (typeof options === "object") { 34 this._needsAuthentication = options[Trac.NeedsAuthentication] === true; 35 // We expect the projectIdentifier option iff the target Trac instance is hosting multiple repositories && Trac version > 1.0 36 this._projectName = options[Trac.ProjectIdentifier]; 37 } 34 38 35 39 this.recordedCommits = []; // Will be sorted in ascending order. … … 41 45 42 46 Trac.NeedsAuthentication = "needsAuthentication"; 47 Trac.ProjectIdentifier = "projectIdentifier"; 43 48 Trac.UpdateInterval = 45000; // 45 seconds 44 49 … … 104 109 revisionURL: function(revision) 105 110 { 106 return this.baseURL + "changeset/" + encodeURIComponent(revision); 111 var url = this.baseURL + "changeset/" + encodeURIComponent(revision); 112 if (this._projectName) 113 url += '/' + encodeURIComponent(this._projectName); 114 return url; 107 115 }, 108 116 … … 113 121 var fromDay = new Date(fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate()); 114 122 var toDay = new Date(toDate.getFullYear(), toDate.getMonth(), toDate.getDate()); 115 116 return this.baseURL + "timeline?changeset=on&format=rss&max=0" + 117 "&from=" + toDay.toISOString().slice(0, 10) + 118 "&daysback=" + ((toDay - fromDay) / 1000 / 60 / 60 / 24); 123 var changesetParameter = this._projectName ? "repo-" + this._projectName : "changeset"; 124 125 return this.baseURL + "timeline?" + 126 changesetParameter + "=on" + 127 "&format=rss" + 128 "&max=0" + 129 "&from=" + encodeURIComponent(toDay.toISOString().slice(0, 10)) + 130 "&daysback=" + encodeURIComponent((toDay - fromDay) / 1000 / 60 / 60 / 24); 119 131 }, 120 132 … … 151 163 if (parsedDescription.firstChild && parsedDescription.firstChild.className === "changes") { 152 164 // We can extract branch information when trac.ini contains "changeset_show_files=location". 153 location = doc.evaluate("//strong", parsedDescription.firstChild, null, XPathResult.STRING_TYPE).stringValue 165 location = doc.evaluate("//strong", parsedDescription.firstChild, null, XPathResult.STRING_TYPE).stringValue; 154 166 parsedDescription.removeChild(parsedDescription.firstChild); 155 167 } -
trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js
r199180 r211388 24 24 */ 25 25 26 MockTrac = function( )26 MockTrac = function(projectIdentifier) 27 27 { 28 Trac.call(this, "https://trac.webkit.org/"); 28 if (projectIdentifier) { 29 var options = { }; 30 options[Trac.ProjectIdentifier] = projectIdentifier; 31 Trac.call(this, "https://trac.webkit.org/", options); 32 } else { 33 Trac.call(this, "https://trac.webkit.org/"); 34 } 29 35 }; 30 36 -
trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js
r201475 r211388 42 42 setup: function() { 43 43 this.trac = new MockTrac(); 44 this.tracWithIdentifier = new MockTrac("webkit"); 44 45 } 45 46 }); … … 120 121 var commits = this.trac.commitsOnBranchInRevisionRange("trunk", "33020", "33022"); 121 122 equal(commits.length, 2, "in range 33020, 33022"); 123 }); 124 125 test("revisionURL", function() 126 { 127 strictEqual(this.trac.revisionURL("33020"), "https://trac.webkit.org/changeset/33020", "changeset URL matches for 33020"); 128 strictEqual(this.trac.revisionURL("0e498db5d8e5b5a342631"), "https://trac.webkit.org/changeset/0e498db5d8e5b5a342631", "changeset URL matches for 0e498db5d8e5b5a342631"); 129 }); 130 131 test("revisionURL with Trac Identifier", function() 132 { 133 strictEqual(this.tracWithIdentifier.revisionURL("33020"), "https://trac.webkit.org/changeset/33020/webkit", "changeset URL matches for 33020"); 134 strictEqual(this.tracWithIdentifier.revisionURL("0e498db5d8e5b5a342631"), "https://trac.webkit.org/changeset/0e498db5d8e5b5a342631/webkit", "changeset URL matches for 0e498db5d8e5b5a342631"); 135 }); 136 137 test("_xmlTimelineURL", function() 138 { 139 var before = new Date("1/1/2017"); 140 var after = new Date("1/2/2017"); 141 142 strictEqual(this.trac._xmlTimelineURL(before, before), "https://trac.webkit.org/timeline?changeset=on&format=rss&max=0&from=2017-01-01&daysback=0"); 143 strictEqual(this.trac._xmlTimelineURL(before, after), "https://trac.webkit.org/timeline?changeset=on&format=rss&max=0&from=2017-01-02&daysback=1"); 144 }); 145 146 test("_xmlTimelineURL with Trac Identifier", function() 147 { 148 var before = new Date("1/1/2017"); 149 var after = new Date("1/2/2017"); 150 151 strictEqual(this.tracWithIdentifier._xmlTimelineURL(before, before), "https://trac.webkit.org/timeline?repo-webkit=on&format=rss&max=0&from=2017-01-01&daysback=0"); 152 strictEqual(this.tracWithIdentifier._xmlTimelineURL(before, after), "https://trac.webkit.org/timeline?repo-webkit=on&format=rss&max=0&from=2017-01-02&daysback=1"); 122 153 }); 123 154 … … 180 211 }; 181 212 return iteration; 182 } 213 }; 183 214 var element = document.createElement("div"); 184 215 var popover = new Dashboard.Popover(); -
trunk/Tools/ChangeLog
r211382 r211388 1 2017-01-30 Kocsen Chung <kocsen_chung@apple.com> 2 3 Add support for Trac instances that host multiple projects. 4 https://bugs.webkit.org/show_bug.cgi?id=167524 5 6 Reviewed by Alexey Proskuryakov. 7 8 When multiple projects are hosted on a single Trac instance, the current 9 behavior will retrieve changesets from all tracked projects. 10 This patch teaches Trac.js to get project-specific changesets from Trac. 11 We do this by replacing the parameter `changeset=on` to `repo-projectname=on` 12 when querying the Trac timeline. 13 14 To tell Trac to be aware of multi-project instances we leverage the 15 `options` parameter when creating a new instance: 16 17 new Trac("https://mytrac.com/", { projectIdentifier: "tracProjectName" }); 18 19 If this option is not provided, the original behaviour will prevail. 20 Additionally, add corresponding tests. 21 22 * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js: 23 (Trac): Reason about new optional parameter 'projectIdentifier'. 24 (Trac.prototype.revisionURL): Given a projectIdentifier, append it to the end of the URL. 25 (Trac.prototype._xmlTimelineURL): Given a projectIdentifier, 26 replace default parameter `changeset=on` with `repo-projectname=on`. 27 (Trac.prototype._convertCommitInfoElementToObject): Fix missing ';'. 28 * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/MockTrac.js: 29 (MockTrac): Add support for instantiating Trac with a projectIdentifier. 30 * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/resources/tests.js: 31 (setup): Provide a multiple-project MockTrac instance to all test cases for testing. 32 Add the following tests: 33 test("revisionURL") 34 test("revisionURL with Trac Identifier") 35 test("_xmlTimelineURL") 36 test("_xmlTimelineURL with Trac Identifier") 37 (this.view._latestProductiveIteration): Fix missing ';'. 38 1 39 2017-01-30 Myles C. Maxfield <mmaxfield@apple.com> 2 40
Note: See TracChangeset
for help on using the changeset viewer.