Skip to content

Instantly share code, notes, and snippets.

@tokland
Last active November 26, 2020 10:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tokland/2a3ddb9a4170be96518c3d82f7acca58 to your computer and use it in GitHub Desktop.
Save tokland/2a3ddb9a4170be96518c3d82f7acca58 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -e -u -o pipefail
# Open a new pull request in github from the current branch
open_pr() {
local base_branch=${1:-"development"}
local merge_organisation_opt=${2:-}
local browser="xdg-open"
local repo current_branch merge_organisation merge_branch url
repo=$(git remote -v | head -n1 | awk '{print $2}' | cut -d: -f2 | cut -d "." -f1)
merge_organisation=$(if test "$merge_organisation_opt"; then
echo "$merge_organisation_opt"
else
echo "$repo" | cut -d"/" -f1
fi)
current_branch=$(git rev-parse --abbrev-ref HEAD)
merge_branch="$merge_organisation:$current_branch"
url="https://github.com/$repo/compare/$base_branch...$merge_branch?expand=1"
$browser "$url"
}
open_pr "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment