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

Commit

Permalink
support for multiple issues (#12)
Browse files Browse the repository at this point in the history
  • Loading branch information
John Levon authored and trentm committed Jul 31, 2019
1 parent 82cb69b commit 40bff97
Show file tree
Hide file tree
Showing 6 changed files with 352 additions and 130 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/tmp
/npm-debug.log
/joyent-grr-*.tgz
/package-lock.json
1 change: 0 additions & 1 deletion TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# TODO

- grr option to adopt an existing CR and patchset
- grr support for *multiple* tickets
- `grr --integrate,-I` that checks for approvals, does the integration,
and then calls `grrDelete`.
- change <parenthetical> to being an *option*, makes it clearer how to update
Expand Down
31 changes: 27 additions & 4 deletions docs/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ CR created: 275 <https://cr.joyent.us/275>
```

It squashes all the commits (in a separate branch used only for this push)
and pushed to gerrit. Now make more commits and `grr` again to update:
and pushes to gerrit. Now make more commits and `grr` again to update:

```
[trentm@danger0:~/tm/play (grr-TOOLS-1516)]
Expand Down Expand Up @@ -116,8 +116,31 @@ It cached the CR number from earlier, so does the right thing on push.
If you look at <https://cr.joyent.us/275>, you'll notice that the commit
message format is handled for you.

When you are done, use `grr -D` to clean up (remove the branch) and it pops
you back to `master`:
If we now end up fixing another issue as part of this CR, we can add it to our
commit message with `grr -a`:

```
[trentm@danger0:~/tm/play (grr-TOOLS-1516)]
$ grr -a TOOLS-1517
...
```

When you have the requisite +1's on gerrit, run `grr` one more time to update
the commit message with the correct `Reviewed-by` and `Approved-by` lines:

```
[trentm@danger0:~/tm/play (grr-TOOLS-1516)]
$ grr
...
```

Be aware: if you try to update the commit message and rebase at the same time,
gerrit gets confused, and drops all of the +1s from the CR.

You can now *Submit* in gerrit to integrate.

Finally, use `grr -D` to clean up (remove the branch), which pops you back to
`master`:

```
[trentm@danger0:~/tm/play (grr-TOOLS-1516)]
Expand All @@ -129,4 +152,4 @@ Deleting local grr branch "grr-TOOLS-1516"
[trentm@danger0:~/tm/play (master)]
$
```
```
21 changes: 20 additions & 1 deletion lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@ var options = [
+ 'was changed.',
'default': false
},
{
names: ['add-extra', 'a'],
type: 'string',
help: 'Add the given comma-separated list of issues to the commit.'
},
{
names: ['remove-extra', 'r'],
type: 'string',
help: 'Remove the given comma-separated list of issues from the commit.'
},
// TODO
//{
// names: ['commit', 'c'],
Expand All @@ -76,7 +86,7 @@ var options = [
// 'default': false
//},
{
group: 'When done your CR'
group: 'When done with your CR'
},
{
names: ['delete', 'D'],
Expand Down Expand Up @@ -121,6 +131,8 @@ function usage() {
' grr TOOLS-123 # Start or update a branch and CR for this ticket',
//' grr --commit TOOLS-123 # ... also commit uncommited changes',
' grr # Update the current CR (using the cached ticket)',
' grr -a TOOLS-124 # Add an extra issue to the current CR',
' grr -r TOOLS-124 # Remove an extra issue from the current CR',
' grr -D # All done. Del the branch and switch back to master'
].join('\n'));
/* END JSSTYLED */
Expand Down Expand Up @@ -183,6 +195,11 @@ function main(argv) {
}

if (opts['delete']) {
if (opts.add_extra || opts.remove_extra) {
console.error('extra issues specified when deleting');
process.exit(1);
}

grr.grrDelete({
log: log,
issueArg: issueArg,
Expand All @@ -195,6 +212,8 @@ function main(argv) {
log: log,
issueArg: issueArg,
parenthetical: opts.parenthetical,
addExtraIssuesArg: opts.add_extra,
removeExtraIssuesArg: opts.remove_extra,
dryRun: opts.dry_run,
commit: opts.commit,
update: opts.update
Expand Down
11 changes: 10 additions & 1 deletion lib/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

/*
* Copyright 2016 Joyent, Inc.
* Copyright 2019 Joyent, Inc.
*/

var assert = require('assert-plus');
Expand All @@ -16,6 +16,14 @@ var VError = require('verror').VError;

// ---- support stuff

/// A split with sensible semantics for forEach().
function fsplit(str, separator) {
return str.split(separator).filter(function (s) {
if (s !== '')
return s;
});
}

function objCopy(obj, target) {
assert.object(obj, 'obj');
assert.optionalObject(obj, 'target');
Expand Down Expand Up @@ -114,6 +122,7 @@ function forkExecWaitAndLog(opts, cb) {
//---- exports

module.exports = {
fsplit: fsplit,
objCopy: objCopy,
deepObjCopy: deepObjCopy,
tildeSync: tildeSync,
Expand Down
Loading

0 comments on commit 40bff97

Please sign in to comment.