diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-26 18:01:36 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2020-03-26 18:01:36 -0400 |
commit | 6de8a6106413068662ca2fa5a98ba2b6aa7f2d7b (patch) | |
tree | d6ac7295c40c740f09db0e9cc73e0052c11ad0e7 /b4/command.py | |
parent | 44ac4f1a78330f029343f31c46e46abc69a25121 (diff) | |
download | b4-6de8a6106413068662ca2fa5a98ba2b6aa7f2d7b.tar.gz |
Add initial "b4 pr" command set
While working on "pull-request exploder" stuff for achiving on
lore.kernel.org, I realized that this may be a useful set of features
for developers as well, so here is a very simple framework for handing
pull requests. Examples:
b4 pr <msgid>
- downloads that message
- parses the pull request
- checks that the remote tip is where the message says it should be
- makes sure the base-commit is present in the tree
- makes sure the tip commit isn't already in one of the branches
- checks if FETCH_HEAD already is at that commit
- if the above two checks pass, performs a git fetch
b4 pr --check <msgid>
Runs all of the checks above, but doesn't perform the actual fetch.
Useful if you don't remember if you've already processed a pull
request or not.
b4 pr --explode <msgid>
Runs basic sanity checks and then:
- performs a git fetch
- runs a "git format-patch" for base-commit..FETCH_HEAD
- adds the same to/from/cc headers as in the pull request
- properly threads each patch below the pull request
- saves that into a <msgid>.mbox file
The above is handy if you want to comment on something in a pull
request and not have to hunt around for sender/cc information.
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/command.py')
-rw-r--r-- | b4/command.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/b4/command.py b/b4/command.py index 3997035..f36f3ea 100644 --- a/b4/command.py +++ b/b4/command.py @@ -50,6 +50,11 @@ def cmd_verify(cmdargs): b4.attest.verify_attestation(cmdargs) +def cmd_pr(cmdargs): + import b4.pr + b4.pr.main(cmdargs) + + def cmd(): parser = argparse.ArgumentParser( description='A tool to work with public-inbox patches', @@ -112,6 +117,22 @@ def cmd(): sp_ver.add_argument('mbox', nargs=1, help='Mbox containing patches to attest') sp_ver.set_defaults(func=cmd_verify) + # b4 pr + sp_pr = subparsers.add_parser('pr', help='Fetch a pull request found in a message ID') + sp_pr.add_argument('-g', '--gitdir', default=None, + help='Operate on this git tree instead of current dir') + sp_pr.add_argument('-b', '--branch', default=None, + help='Check out FETCH_HEAD into this branch after fetching') + sp_pr.add_argument('-c', '--check', action='store_true', default=False, + help='Check if pull request has already been applied') + sp_pr.add_argument('-e', '--explode', action='store_true', default=False, + help='Convert a pull request into an mbox full of patches') + sp_pr.add_argument('-o', '--output-mbox', dest='outmbox', default=None, + help='Save exploded messages into this mailbox (default: msgid.mbx)') + sp_pr.add_argument('msgid', nargs='?', + help='Message ID to process, or pipe a raw message') + sp_pr.set_defaults(func=cmd_pr) + cmdargs = parser.parse_args() logger.setLevel(logging.DEBUG) |