Last active
November 1, 2023 11:54
-
-
Save pugson/df144a8e49af3ddc70b21e5a28e8094b to your computer and use it in GitHub Desktop.
open repo in the browser and submit PR
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
alias repo="open `git remote -v | grep fetch | awk '{print $2}' | sed 's/git@/http:\/\//' | sed 's/com:/com\//'`| head -n1" | |
# Open the Pull Request URL for your current directory's branch (base branch defaults to master) | |
function openpr() { | |
github_url=`git remote -v | awk '/fetch/{print $2}' | sed -Ee 's#(git@|git://)#https://#' -e 's@com:@com/@' -e 's%\.git$%%' | awk '/github/'`; | |
branch_name=`git symbolic-ref HEAD | cut -d"/" -f 3,4`; | |
pr_url=$github_url"/compare/main..."$branch_name | |
open $pr_url; | |
} | |
# Run git push and then immediately open the Pull Request URL | |
function gpr() { | |
git push origin HEAD | |
if [ $? -eq 0 ]; then | |
openpr | |
else | |
echo 'failed to push commits and open a pull request.'; | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment