Last active
November 26, 2020 10:54
-
-
Save tokland/2a3ddb9a4170be96518c3d82f7acca58 to your computer and use it in GitHub Desktop.
This file contains 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 | |
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