Last active
May 2, 2018 17:06
-
-
Save catvec/aa2251e2a05af3d1e0a94f4d93901849 to your computer and use it in GitHub Desktop.
Opens the GitHub Pull Request page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # | |
| # Usage: open-pr [--upstream UPSTREAM_BRANCH] [--current CURRENT_BRANCH] | |
| # | |
| # Args: | |
| # --upstream/-u: (Optional) Upstream branch to create PR for, default to | |
| # "develop" | |
| # --current/-c: (Optional) Local branch to create PR for, default to the | |
| # current branch | |
| # | |
| # Configuration: | |
| # - opener: Link open command on your system, for OSX it is "open" for most | |
| # linux systems it is "xdg-open" | |
| # - upstream_owner: Owner of upstream repository to open PR for | |
| # - self_owner: Your GitHub username | |
| opener=open | |
| # Repo info | |
| upstream_owner=AminoPay | |
| self_owner=Noah-Huppert | |
| repo_name=$(basename `git remote get-url origin` | sed -e 's/.git//') | |
| # Args | |
| upstream_branch=develop | |
| self_branch=$(git rev-parse --abbrev-ref HEAD) | |
| while [[ ! -z "$1" ]]; do | |
| key="$1" | |
| shift | |
| case "$key" in | |
| --upstream|-u) | |
| upstream_branch="$1" | |
| shift | |
| ;; | |
| --current|-c) | |
| self_branch="$1" | |
| shift | |
| ;; | |
| *) | |
| echo "Unknown argument: $key" | |
| exit 1 | |
| ;; | |
| esac | |
| done | |
| # Open URL | |
| echo "Opening PR URL for $upstream_owner/${repo_name}:$upstream_branch -> $self_owner/${repo_name}:$self_branch" | |
| pr_url="https://github.com/$upstream_owner/$repo_name/compare/$upstream_branch...$self_owner:$self_branch" | |
| "$opener" "$pr_url" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment