Skip to content
This repository has been archived by the owner on Dec 31, 2019. It is now read-only.

Add -L option to list open CRs #6

Closed
wants to merge 3 commits into from
Closed

Add -L option to list open CRs #6

wants to merge 3 commits into from

Conversation

timfoster
Copy link
Contributor

This pull request lets developers see what other CRs are pending for the current repository.

(note, this is not the same as the '-l' option requested by #3
which shows which grr branches exist for the current local repository)

This -L support could be useful for two things:

a) let developers see what CR backlog there may be, if they're interested in clearing that
b) let developers see what existing CRs may clash with their intended changes

Copy link
Contributor

@trentm trentm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Some notes below.

};

vasync.pipeline({arg: context, funcs: [
stepGetGrrConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to add stepGetGrrCache here else I get:

[10:06:26 trentm@bluesteel:~/joy/sdcadm (cr-4658-3)]
$ ~/joy/grr2/bin/grr -L
/Users/trentm/joy/grr2/lib/grr.js:176
    } else if (arg.grrCache.gerritUsername) {
                           ^

TypeError: Cannot read property 'gerritUsername' of undefined
    at Object.stepGetGerritUsername [as func] (/Users/trentm/joy/grr2/lib/grr.js:176:28)
    at Immediate._onImmediate (/Users/trentm/joy/grr2/node_modules/vasync/lib/vasync.js:213:20)
    at processImmediate [as _immediateCallback] (timers.js:396:17)

return
}

var fmt = '%-26s%-27s%-30s%s';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use tabula for table printing here, please? https://github.com/trentm/node-tabula#usage

The best usage docs are this: https://github.com/trentm/node-tabula/blob/master/lib/tabula.js#L199-L237

A first stab usage here would be:

var tabula = require('tabula');

// ...

var crs = lines
    .slice(0, -1)
    .map(function (line) { return JSON.parse(line); });

crs.forEach(function (cr) {
    cr.created = new Date(cr.createdOn * 1000).toISOString()
        .split(/T/)[0]; // Elide the time of day.
})

tabula(crs, {
    columns: [
        {lookup: 'created'},
        {lookup: 'url'},
        {lookup: 'owner.email', name: 'OWNER'},
        {lookup: 'subject'}
    ],
    dottedLookup: true,
    sort: ['created']
});

Some tweaks for discussion:

  • tabula will handle column widths, and offers sorting
  • I used "OWNER" rather than "AUTHOR" to copy gerrit's terminology
  • Ditto for "SUBJECT". However I haven't clipped the subject at 80 columns.
    I'm not sure how valuable that is, given that often the whole table will
    exceed 80 columns anyway. In general I'd prefer to show all the data.
  • I elided the time of day in the 'CREATED' column for brevity.

lib/grr.js Outdated
assert.func(cb, 'cb');

var context = {
log: opts.log,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are some make check failures to sort out:

$ make check
version is: 1.6.0
[[ `cat package.json | json version` == `grep '^## ' CHANGES.md | head -2 | tail -1 | awk '{print $2}'` ]]
deps/javascriptlint/build/install/jsl --nologo --nosummary --nofilelist --conf=tools/jsl.node.conf bin/grr lib/index.js lib/grr.js lib/config.js lib/common.js lib/cli.js
/Users/trentm/joy/grr2/lib/grr.js(1287): warning: trailing_comma
/Users/trentm/joy/grr2/lib/grr.js(1189): warning: missing semicolon
/Users/trentm/joy/grr2/lib/grr.js(1196): warning: variable res hides argument
/Users/trentm/joy/grr2/lib/grr.js(1198): warning: comparisons against null, 0, true, false, or an empty string allowing implicit type conversion (use === or !==)
/Users/trentm/joy/grr2/lib/cli.js(192): warning: trailing_comma
make: *** [check-jsl-node] Error 1

(For the future: Frankly personally I'm fine with trailing commas. Eventually this repo should move to eslint and we can try to reach some commonality on styles for sets of Joyent repos.)

@trentm
Copy link
Contributor

trentm commented Mar 19, 2019

@timfoster Oh, this PR now has all the grr -r-review-related changes in it. Was that intentional?

@timfoster
Copy link
Contributor Author

Urgh, no it wasn't - I'll see if I can work out how to remove those. (maybe the expected github workflow to maintain a separate fork for each PR?)

@timfoster
Copy link
Contributor Author

Ok, it looks like separating pull requests by branches is the way to go. It doesn't look like there's a way to switch the source branch of this pull request from 'master' to the new 'grr-list' branch I pushed, so I'm going to close this one and create a new one. Hopefully github will let me link to this conversation so we don't lose the history.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants