Bug 153624 - Add code to parse the git branches out of the Trac RSS feed
Summary: Add code to parse the git branches out of the Trac RSS feed
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: Tools / Tests (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks: 152345
  Show dependency treegraph
 
Reported: 2016-01-28 17:15 PST by Jason Marcell
Modified: 2016-02-01 16:56 PST (History)
7 users (show)

See Also:


Attachments
Patch (6.52 KB, patch)
2016-01-28 17:17 PST, Jason Marcell
no flags Details | Formatted Diff | Diff
Adds git branches to the timeline RSS feed (1.37 KB, application/rss+xml)
2016-02-01 11:44 PST, Jason Marcell
no flags Details
Patch (14.17 KB, patch)
2016-02-01 14:35 PST, Jason Marcell
no flags Details | Formatted Diff | Diff
Patch (14.88 KB, patch)
2016-02-01 16:19 PST, Jason Marcell
dbates: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Marcell 2016-01-28 17:15:22 PST
Add code to parse the git branches out of the Trac RSS feed
Comment 1 Jason Marcell 2016-01-28 17:17:42 PST
Created attachment 270165 [details]
Patch
Comment 2 Daniel Bates 2016-01-28 19:34:27 PST
Comment on attachment 270165 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270165&action=review

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:69
> +            return (!commit.containsBranchLocation || commit.branchName === branchName || (commit.branchName instanceof Array && commit.branchName.includes(branchName))) && filter(commit);

This does not seem like the correct approach. In particular, its weird that branchName could be either a String object or an Array object.

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:172
> +        var gitBranches = doc.evaluate("./branches", commitElement, null, XPathResult.STRING_TYPE).stringValue;
> +        if (gitBranches) {
> +            result.containsBranchLocation = true;
> +            result.branchName = gitBranches.split(", ");
> +        }

We need a test case for a multi-branch commit.

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js:60
> +    strictEqual(commits.length, 6, "should have 6 commits");

It's weird that there are six commits because on first glance this test only parses a single commit. I know that five of these commits are hardcoded in class MockTrac. Can we extract the hardcoded recorded commits from MockTrac into some kind of constant, maybe MockTrac.EXAMPLE_TRAC_COMMITS, such that MockTrac has no recorded commits by default? Unit tests that want to make use of this set of mock commits could then set MockTrac.recordedCommits = MockTrac.EXAMPLE_TRAC_COMMITS. And we would not make use of this set of commits for this test.
Comment 3 Jason Marcell 2016-02-01 11:44:19 PST
Created attachment 270409 [details]
Adds git branches to the timeline RSS feed

Alexey suggested checking this into the repository somewhere but I'm not sure where it belongs.
Comment 4 Jason Marcell 2016-02-01 14:35:01 PST
Created attachment 270426 [details]
Patch
Comment 5 Jason Marcell 2016-02-01 14:37:04 PST
(In reply to comment #2)
> Comment on attachment 270165 [details]
> Patch
> 
> View in context:
> https://bugs.webkit.org/attachment.cgi?id=270165&action=review
> 
> > Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:69
> > +            return (!commit.containsBranchLocation || commit.branchName === branchName || (commit.branchName instanceof Array && commit.branchName.includes(branchName))) && filter(commit);
> 
> This does not seem like the correct approach. In particular, its weird that
> branchName could be either a String object or an Array object.

I addressed this in the latest patch. I refactored 'branchName' to be 'branches', changed the type of the variable to be an array, and updated the code that interacts with it accordingly.

> 
> > Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:172
> > +        var gitBranches = doc.evaluate("./branches", commitElement, null, XPathResult.STRING_TYPE).stringValue;
> > +        if (gitBranches) {
> > +            result.containsBranchLocation = true;
> > +            result.branchName = gitBranches.split(", ");
> > +        }
> 
> We need a test case for a multi-branch commit.

I added a test case and corresponding assertions for a multi-branch commit.

> 
> > Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js:60
> > +    strictEqual(commits.length, 6, "should have 6 commits");
> 
> It's weird that there are six commits because on first glance this test only
> parses a single commit. I know that five of these commits are hardcoded in
> class MockTrac. Can we extract the hardcoded recorded commits from MockTrac
> into some kind of constant, maybe MockTrac.EXAMPLE_TRAC_COMMITS, such that
> MockTrac has no recorded commits by default? Unit tests that want to make
> use of this set of mock commits could then set MockTrac.recordedCommits =
> MockTrac.EXAMPLE_TRAC_COMMITS. And we would not make use of this set of
> commits for this test.

I did this in the latest patch as well.
Comment 6 Daniel Bates 2016-02-01 15:21:16 PST
Comment on attachment 270426 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270426&action=review

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/Trac.js:169
> +        var gitBranches = doc.evaluate("./branches", commitElement, null, XPathResult.STRING_TYPE).stringValue;

I am assuming that doc.evaluate("./branches", commitElement, null, XPathResult.STRING_TYPE) always returns an object. We should add a test case for an entry that does not have <branches>.

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js:54
> +    client.open('GET', 'test-fixture-git-trac-rss.xml', false);

Nit: We use single quoted string literals here and double quoted string literals below. We should pick one quoting style for string literals and stick with it.

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js:58
> +    client.onreadystatechange = function () {
> +        if (client.readyState === client.DONE)
> +            this.trac._loaded(client.responseXML);
> +    }.bind(this);

Nit: We're underutilizing the the onreadystatechange listener. Since we only care if the load completed successfully, we could register a onload listener. See <https://xhr.spec.whatwg.org/#event-handlers> for a list of the event handlers that can be registered on XMLHttpRequest.
Comment 7 Jason Marcell 2016-02-01 16:19:26 PST
Created attachment 270448 [details]
Patch
Comment 8 Daniel Bates 2016-02-01 16:28:28 PST
Comment on attachment 270448 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270448&action=review

> Tools/ChangeLog:3
> +        Add code to parse the git branches out of the Trac RSS feed.

Nit: Remove the period at the end of this line so that it reflects the name of this bug.

> Tools/ChangeLog:9
> +        (Trac.prototype.commitsOnBranch): Update filter to check for git branches.

Nit: git => Git

> Tools/ChangeLog:10
> +        (Trac.prototype._convertCommitInfoElementToObject): Parse git branches from the Trac RSS feed. Also changed "branchName" to

Ditto.

> Tools/ChangeLog:15
> +        fixture that contains XML with a git branch.

Ditto.

> Tools/ChangeLog:16
> +        * BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js: Added unit test to test parsing git

Ditto.

> Tools/BuildSlaveSupport/build.webkit.org-config/public_html/dashboard/Scripts/tests/tests.js:59
> +    strictEqual(commits.length, 3, "should have 2 commits");

2 => 3
Comment 9 Jason Marcell 2016-02-01 16:56:36 PST
Landed: http://trac.webkit.org/changeset/195993