Last active
March 10, 2021 19:32
-
-
Save matthewoden/35b0a2a99bf50efec70d79e6bda5ee3d to your computer and use it in GitHub Desktop.
Publish, and open 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
#!/usr/bin/env bash | |
# Created by Matthew Potter, March 2020 | |
# Publish a branch to the upstream origin, then open the url. | |
# | |
# git alias example (note - not a bash alias): | |
# publish = "!git push -u origin $(git rev-parse --abbrev-ref HEAD) && ~/path/to/script/POST_PUSH" | |
# usage: | |
# git publish | |
branch=$(git rev-parse --abbrev-ref HEAD) | |
# github.com, or your enterprise host | |
host="YOUR_HOST" | |
# on github, this is output as org/repo | |
userRepo=$(git remote -v | grep fetch | awk '{print $2}' | grep $host | cut -d':' -f2 | rev | cut -c5- | rev) | |
if [ -n "$userRepo" ] | |
then | |
# formatted for github style PRs, but easy enough to change around for whatever git UI you use. | |
open "https://$host/$userRepo/compare/$branch?expand=1" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment