git-pr

A git command for fetching GitHub’s pull requests to local copy. Please do not hesitate to contribute by any means you can and/or want:

  • by submitting patches
  • by filing bugs
Source https://github.com/ikalnitsky/git-pr/
Bugs https://github.com/ikalnitsky/git-pr/issues

Table Of Contents

Installation

This part of the documentation covers the installation of git-pr. The first step to using any software package is getting it properly installed.

Requirements

OS / Python 2.7 3.3 3.4 3.5 3.6 pypy
Linux yes yes yes yes yes maybe
OS X yes yes yes yes yes maybe
Windows maybe maybe maybe maybe maybe maybe

Note

In the table above, maybe means that the project should work fine with proper installation. However, the configuration isn’t a part of testing gates on CI, so there’s no guarantee it works.

Install via pip

A universal installation method that works on Linux, OS X and even Windows.

$ [sudo] pip install git-pr

Usage

git-pr provides a simple command line interface with the following synopsis:

git pr [repository] pull_request [--branch test]

Fetch

Usually you just need to run the following short command in order to fetch pull request with ID=42:

$ git pr 42

When it’s done, you’ll be automatically switched to fetched commit(s).

Note

By default, the origin remote is assumed. So please make sure it points to GitHub, otherwise the command will fail.

Fetch From Remote

Sometimes origin remote is configured to point to some internal or private repo. In this case you must specify explicitly remote that points to GitHub mirror:

$ git pr github 42

It behaves exactly like the command above, but unlike last one the github remote will be used instead of origin.

Fetch From URL

If, by some reason, you don’t have a remote pointed to GitHub, you can specify repo URL instead:

$ git pr https://github.com/ikalnitsky/git-pr.git 42

Fetch To New Branch

By default, you’re in detached state after fetching. So if you switch to other branch in order to do some work you won’t be able to switch back.

That’s why git-pr supports a way to fetch a pull request into a new branch. In order to do so you have to pass either -b or --branch argument with a branch name:

$ git pr 42 -b pr/42

When it’s done, the pr/42 local branch is created with content of the pull request with ID=42.

Fetch Merge Commit

Each pull request produces two refs:

  • one, that points to submitted pull request as its author submitted it;
  • one, that points to a merge commit of a pull request and a branch it’s submitted to;

By default, git-pr fetches the first one. If you want to fetch the second one, you’ve got to pass either -m or --merge argument:

$ git pr 42 --merge

Fetch Without Checkout

By default, when a pull request is fetched, git-pr automatically checkouts to the fetched copy. It’s not something you always want, so if you need to turn it off just pass either -C or --no-checkout argument:

$ git pr 42 --no-checkout

Changes

Here you can see the list of changes between each git-pr release.

0.2.0 (2017-03-19)

  • Drop Python 3.2 support simply because it’s dead (reached end of life).
  • New argument: -m, --merge. The flag is used to fetch a merge commit of a given pull request and a branch the pull request is submitted to.
  • New argument: -C, --no-checkout. The flag is used to do not fetch over to fetched pull request and keep this step up to user.

0.1.0 (2015-10-17)

  • First public release.

License

The MIT License (MIT)

Copyright (c) 2015 Ihor Kalnytskyi

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.