Skip to content

Instantly share code, notes, and snippets.

@SirJson
Created February 6, 2020 01:40
Show Gist options
  • Save SirJson/d200f5c07da38c0c6c38c2b5ee4f04b7 to your computer and use it in GitHub Desktop.
Save SirJson/d200f5c07da38c0c6c38c2b5ee4f04b7 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
"""
usage: git fetchpr <PULL_REQUEST_ID>
Arguments:
PULL_REQUEST_ID The pull request id
If an 'upstream' repository is configured this command can fetch unmerged pull requests to your local repository.
The PULL_REQUEST_ID can be found in on Github upstream pull request page.
After successful execution a new local branch called pr<PULL_REQUEST_ID> will be setup for you.
"""
from docopt import docopt
from subprocess import run
if __name__ == '__main__':
arguments = docopt(__doc__, options_first=True)
prid = int(arguments['<PULL_REQUEST_ID>'])
run(['git', 'fetch', 'upstream', f'pull/{prid}/head:pr{prid}'], check=True)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment