<html>
    <head>
      <base href="https://bugs.webkit.org/" />
    </head>
    <body><span class="vcard"><a class="email" href="mailto:rniwa&#64;webkit.org" title="Ryosuke Niwa &lt;rniwa&#64;webkit.org&gt;"> <span class="fn">Ryosuke Niwa</span></a>
</span> changed
              <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Rewrite 'pull-os-versions' script in JavaScript and add ability to report os commits with sub-commits."
   href="https://bugs.webkit.org/show_bug.cgi?id=169542">bug 169542</a>
        <br>
             <table border="1" cellspacing="0" cellpadding="8">
          <tr>
            <th>What</th>
            <th>Removed</th>
            <th>Added</th>
          </tr>

         <tr>
           <td style="text-align:right;">Attachment #304475 Flags</td>
           <td>review?
           </td>
           <td>review+
           </td>
         </tr></table>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Rewrite 'pull-os-versions' script in JavaScript and add ability to report os commits with sub-commits."
   href="https://bugs.webkit.org/show_bug.cgi?id=169542#c5">Comment # 5</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - Rewrite 'pull-os-versions' script in JavaScript and add ability to report os commits with sub-commits."
   href="https://bugs.webkit.org/show_bug.cgi?id=169542">bug 169542</a>
              from <span class="vcard"><a class="email" href="mailto:rniwa&#64;webkit.org" title="Ryosuke Niwa &lt;rniwa&#64;webkit.org&gt;"> <span class="fn">Ryosuke Niwa</span></a>
</span></b>
        <pre>Comment on <span class=""><a href="attachment.cgi?id=304475&amp;action=diff" name="attach_304475" title="Patch">attachment 304475</a> <a href="attachment.cgi?id=304475&amp;action=edit" title="Patch">[details]</a></span>
Patch

View in context: <a href="https://bugs.webkit.org/attachment.cgi?id=304475&amp;action=review">https://bugs.webkit.org/attachment.cgi?id=304475&amp;action=review</a>

<span class="quote">&gt; Websites/perf.webkit.org/public/include/commit-log-fetcher.php:88
&gt; +    function fetch_last_reported_between_orders($repository_id, $from=NULL, $to=NULL)</span >

I don't think we should make $from and $to optional if the function name says between_orders.

<span class="quote">&gt; Websites/perf.webkit.org/public/include/commit-log-fetcher.php:97
&gt; +        $statements = 'SELECT commit_id as &quot;id&quot;,
&gt; +            commit_revision as &quot;revision&quot;,
&gt; +            commit_previous_commit as &quot;previousCommit&quot;,
&gt; +            commit_time as &quot;time&quot;,
&gt; +            commit_order as &quot;order&quot;,
&gt; +            committer_name as &quot;authorName&quot;,
&gt; +            committer_account as &quot;authorEmail&quot;,
&gt; +            commit_message as &quot;message&quot;</span >

Instead of repeating these names, we can just fetch * and then call format_single_commit.

<span class="quote">&gt; Websites/perf.webkit.org/public/include/commit-log-fetcher.php:100
&gt; +        if ($from &amp;&amp; $to) {</span >

Get rid of this if.

<span class="quote">&gt; Websites/perf.webkit.org/public/include/commit-log-fetcher.php:103
&gt; +            $statements .= ' AND commit_order &gt;=' . $from . ' AND commit_order &lt;= ' . $to . ' ORDER BY commit_order DESC LIMIT 1';</span >

Please use $1 and $2 instead.

<span class="quote">&gt; Websites/perf.webkit.org/public/include/commit-log-fetcher.php:112
&gt; +        foreach ($commits as &amp;$commit)
&gt; +            $commit['time'] = Database::to_js_time($commit['time']);
&gt; +</span >

This is in fact not fetching committer information so this API is kind of broken.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/api-report-commits-tests.js:301
&gt; -    it(&quot;should distinguish between repositories with the asme name but with a different owner.&quot;, () =&gt; {
&gt; +    it(&quot;should distinguish between repositories with the same name but with a different owner.&quot;, function () {</span >

Keep the arrow function.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/resources/mock-subprocess.js:30
&gt; +        var originalSubprocess = global.Subprocess;</span >

Use const.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js:35
&gt; +        'WebKit': {
&gt; +            'revision': '141978',
&gt; +        }</span >

Might wanna put this in a single line for simplicity.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js:41
&gt; +        'WebKit': {
&gt; +            'revision': '141999',
&gt; +        }</span >

Ditto.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js:50
&gt; +        'WebKit': {
&gt; +            'revision': '142000',
&gt; +        },
&gt; +        'JavaScriptCore': {
&gt; +            'revision': '142000',
&gt; +        }</span >

Ditto.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js:106
&gt; +        it('should calculate the right order for a given valid revision', (done) =&gt; {</span >

For sync tests, you don't need &quot;done&quot; at all.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js:134
&gt; +            const fetchCommitsPromise = fetchter._commitsForAvailableBuilds('OSX', ['list', 'build1'], '^\\.*$', 1604000000);</span >

Please declare a local variable like &quot;const minimumOrder = 1604000000&quot; so that the number doesn't look as mysterious.

<span class="quote">&gt; Websites/perf.webkit.org/server-tests/tools-os-build-fetcher-tests.js:148
&gt; +                assert.equal(results.length, 2);
&gt; +                assert.equal(results[0]['repository'], 'OSX');
&gt; +                assert.equal(results[0]['revision'], '16E321z');
&gt; +                assert.equal(results[0]['order'], 1604032126);
&gt; +                assert.equal(results[1]['repository'], 'OSX');
&gt; +                assert.equal(results[1]['revision'], '16F321');
&gt; +                assert.equal(results[1]['order'], 1605032100);</span >

You might wanna just do deepEqual here.

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/os-build-fetcher.js:23
&gt; +        return Promise.all(customCommands.map(command =&gt; {</span >

Nit: We usually wrap arguments in ().

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/os-build-fetcher.js:29
&gt; +            let fetchCommitsPromise = this._remoteAPI.getJSONWithStatus(`/api/commits/${escape(repositoryName)}/last-reported?from=${minRevisionOrder}&amp;to=${maxRevisionOrder}`).then(result =&gt; {</span >

I think we usually wrap argument in () for arrow functions as in (result) =&gt; {

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/os-build-fetcher.js:45
&gt; +        const buildNameRegex = /(\d+)([a-zA-z])(\d+)([a-zA-z]*)/;</span >

It should be A-Z, not A-z. You might wanna even add a test!

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/os-build-fetcher.js:71
&gt; +        commits.forEach((commit) =&gt; {</span >

I think it reads better to use &quot;for (let commit of commits)&quot;

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/os-build-fetcher.js:75
&gt; +                        commit['subCommits'] = JSON.parse(subCommitOutput);</span >

I think we should verify that the content returned by the command in a good form.
We might wanna extract that as a separate function along with the call to _subprocess.execute.

And then use Array.prototype.reduce:
return commits.reduce((promise, commit) =&gt; {
    return promise.then(this._executeSubCommitCommand(command, commit['revision']));
}, Promise.resolve());

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/os-build-fetcher.js:89
&gt; +    fetchAndReportNewBuilds()</span >

Again, please put this right after the constructor.

<span class="quote">&gt; Websites/perf.webkit.org/tools/js/subprocess.js:5
&gt; +    call(command) {</span >

We probably should not call this function &quot;call&quot; since we have <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/call</a>.
execute()?

<span class="quote">&gt; Websites/perf.webkit.org/tools/pull-os-versions.js:30
&gt; +    // v3 models use the global RemoteAPI to access the perf dashboard.
&gt; +    global.RemoteAPI = new RemoteAPI(serverConfig.server);</span >

You can just get rid of the global RemoteAPI here.
I don't any code uses it.

<span class="quote">&gt; Websites/perf.webkit.org/tools/pull-os-versions.js:34
&gt; +    Promise.all(
&gt; +        osConfigList.map(osConfig =&gt; new OSBuildFetcher(osConfig, global.RemoteAPI, new Subprocess, serverConfig.slave, console))
&gt; +    ).catch(function (error) {</span >

I think it reads better to put these three lines into one.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>