/pr
Last active
July 15, 2022 10:54
Revisions
-
spmason revised this gist
Dec 15, 2021 . 1 changed file with 11 additions and 11 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -11,12 +11,11 @@ # (this is how `hub clone` and then `hub fork` should set things up) PUSH_ARGS="" SHOW_BROWSER=1 LOCAL_BRANCH=$(git branch | grep ^\* | sed 's/^* //') BOX=$(uname -s) USERNAME=$(gh api user --jq .login) MERGE_BRANCH=$(gh repo view --json defaultBranchRef --jq .defaultBranchRef.name) while test $# -gt 0 do @@ -41,21 +40,22 @@ if ! git remote | grep $USERNAME 1> /dev/null; then REMOTE=origin fi git push ${REMOTE} ${LOCAL_BRANCH} ${PUSH_ARGS} if ! gh pr view ${REMOTE}:${LOCAL_BRANCH} --json url --jq .url &> /dev/null; then if [[ $SHOW_BROWSER == 1 ]]; then # Open browser to create new PR HEAD="${REMOTE}:${LOCAL_BRANCH}" if [[ "${REMOTE}" = "origin" ]]; then echo "Remote is ${REMOTE}" HEAD="${LOCAL_BRANCH}" fi gh pr create --web --head "$HEAD" fi elif [[ $SHOW_BROWSER == 1 ]]; then # Show existing PR gh pr view ${REMOTE}:${LOCAL_BRANCH} --web else # Just output the PR URL gh pr view ${REMOTE}:${LOCAL_BRANCH} --json url --jq .url fi -
spmason revised this gist
Mar 4, 2021 . 1 changed file with 4 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -48,8 +48,10 @@ fi git push ${REMOTE} ${LOCAL_BRANCH} ${PUSH_ARGS} if ! hub pr show --url &> /dev/null; then if [[ $SHOW_BROWSER == 1 ]]; then # Open browser to create new PR hub compare -b "${MERGE_BRANCH}" ${HUB_ARGS} fi elif [[ $SHOW_BROWSER == 1 ]]; then # Show existing PR hub pr show -
spmason revised this gist
Mar 4, 2021 . 1 changed file with 30 additions and 53 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -6,77 +6,54 @@ # on the branch you want to open a Pull Request for # # NOTES: # - Uses the `hub` tool: https://cli.github.com/ # - Assumes that the upstream repository is called 'origin' and your fork is named after your github username # (this is how `hub clone` and then `hub fork` should set things up) PUSH_ARGS="" HUB_ARGS="" SHOW_BROWSER=1 LOCAL_BRANCH=$(git branch | grep ^\* | sed 's/^* //') BOX=$(uname -s) USERNAME=$(hub api user | jq .login -r) MERGE_BRANCH=master while test $# -gt 0 do case "$1" in --force) PUSH_ARGS="--force-with-lease" ;; -f) PUSH_ARGS="--force-with-lease" ;; --no-browser) SHOW_BROWSER=0 ;; -n) SHOW_BROWSER=0 ;; *) MERGE_BRANCH=$1 ;; esac shift done REMOTE=$USERNAME if ! git remote | grep $USERNAME 1> /dev/null; then echo "No remote $USERNAME found. Pushing to origin" REMOTE=origin fi if [[ $SHOW_BROWSER == 0 ]]; then HUB_ARGS="$HUB_ARGS --url" fi git push ${REMOTE} ${LOCAL_BRANCH} ${PUSH_ARGS} if ! hub pr show --url &> /dev/null; then # Open browser to create new PR hub compare -b "${MERGE_BRANCH}" ${HUB_ARGS} elif [[ $SHOW_BROWSER == 1 ]]; then # Show existing PR hub pr show else # Just output the PR URL hub pr show --url fi -
spmason revised this gist
Sep 29, 2017 . No changes.There are no files selected for viewing
-
spmason revised this gist
Aug 12, 2015 . 1 changed file with 30 additions and 10 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,7 @@ # GitHub "Open Pull Request" script # # Add somewhere in your path, then opening a PR is as easy as typing `pr` while you're # on the branch you want to open a Pull Request for # # NOTES: @@ -14,11 +14,29 @@ # eg $ git config pr.githuburl "https://git.mycompany.com" set -e PUSH_ARGS="" OPENBROWSER=1 LOCAL_BRANCH=`git branch | grep ^\* | sed 's/^* //'` BOX=`uname -s` while test $# -gt 0 do case "$1" in --force) PUSH_ARGS="--force" ;; -f) PUSH_ARGS="--force" ;; --no-browser) OPENBROWSER=0 ;; -n) OPENBROWSER=0 ;; *) MERGE_BRANCH=$1 ;; esac shift done git push origin $LOCAL_BRANCH $PUSH_ARGS set +e ORIGIN_ORG_NAME=`git config remote.origin.url | sed -E 's/.*:(.*)\/.*/\1/'` @@ -52,11 +70,13 @@ fi URL=$GITHUB_URL/$UPSTREAM_ORG_NAME/$REPO_NAME/pull/new/$MERGE_BRANCH...$ORIGIN_ORG_NAME:$LOCAL_BRANCH if [ "$OPENBROWSER" == "1" ]; then echo Opening $URL if [ "$BOX" == "Linux" ]; then xdg-open $URL > /dev/null elif [ "$BOX" == "Darwin" ]; then open $URL else explorer.exe $URL fi fi -
spmason revised this gist
Jan 13, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -24,7 +24,7 @@ set +e ORIGIN_ORG_NAME=`git config remote.origin.url | sed -E 's/.*:(.*)\/.*/\1/'` UPSTREAM_ORG_NAME=`git config remote.upstream.url | sed -E 's/.*:(.*)\/.*/\1/'` REPO_NAME=`git config remote.upstream.url | sed -E 's/.*\/([^\/]*)\.git/\1/'` GITHUB_URL=`git config pr.githuburl` set -e if [ "$GITHUB_URL" == "" ]; then -
spmason revised this gist
Jan 13, 2014 . 1 changed file with 10 additions and 6 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,17 @@ #!/usr/bin/env bash # GitHub "Open Pull Request" script # # Add somewhere in your path, then opening a PR is as easy as typing `pr` while you're # on the branch you want to open a Pull Request for # # NOTES: # - If working from a fork, name your fork's remote "origin" and the main repo "upstream" # - `pr <branch_name>` will open a PR against the branch you give - rather than "master". # - Use `git config pr.defaultbranch <branch_name>` to tell this script the correct branch # to use by default (ie if your repos default branch is not "master") # - If you're working against a GitHub enterprise instance, set the github URL with `git config pr.githuburl` # eg $ git config pr.githuburl "https://git.mycompany.com" set -e LOCAL_BRANCH=`git branch | grep ^\* | sed 's/^* //'` @@ -53,6 +58,5 @@ if [ "$BOX" == "Linux" ]; then elif [ "$BOX" == "Darwin" ]; then open $URL else explorer.exe $URL fi -
spmason revised this gist
Dec 10, 2013 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -7,7 +7,6 @@ # - If working from a fork, name your fork's remove "origin" and the main repo "upstream" # - Use pr <branch_name> to open a PR against a branch other than "master". If the default branch is not "master", use `git config pr.defaultbranch <branch_name>` to tell this script the correct branch to use # - If you're working against a GitHub enterprise instance, set `git config pr.githuburl` set -e LOCAL_BRANCH=`git branch | grep ^\* | sed 's/^* //'` @@ -16,15 +15,16 @@ BOX=`uname -s` git push origin $LOCAL_BRANCH set +e ORIGIN_ORG_NAME=`git config remote.origin.url | sed -E 's/.*:(.*)\/.*/\1/'` UPSTREAM_ORG_NAME=`git config remote.upstream.url | sed -E 's/.*:(.*)\/.*/\1/'` REPO_NAME=`git config remote.upstream.url | sed -E 's/.*\/([^\/]*)\.git/\1/'` GITHUB_URL=`git config pr.github.url` set -e if [ "$GITHUB_URL" == "" ]; then GITHUB_URL=https://github.com fi if [ "$MERGE_BRANCH" == "" ]; then set +e MERGE_BRANCH=`git config pr.defaultbranch` -
spmason revised this gist
Dec 10, 2013 . 1 changed file with 11 additions and 5 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,12 @@ #!/usr/bin/env bash # GitHub "open PR" script # Add somewhere in your path, then opening a PR is as easy as typing `pr` on the branch you want to opena PR for # # NOTES: # - If working from a fork, name your fork's remove "origin" and the main repo "upstream" # - Use pr <branch_name> to open a PR against a branch other than "master". If the default branch is not "master", use `git config pr.defaultbranch <branch_name>` to tell this script the correct branch to use # - If you're working against a GitHub enterprise instance, set `git config pr.githuburl` set -e @@ -18,11 +19,16 @@ git push origin $LOCAL_BRANCH ORIGIN_ORG_NAME=`git config remote.origin.url | sed -E 's/.*:(.*)\/.*/\1/'` UPSTREAM_ORG_NAME=`git config remote.upstream.url | sed -E 's/.*:(.*)\/.*/\1/'` REPO_NAME=`git config remote.upstream.url | sed -E 's/.*\/([^\/]*)\.git/\1/'` GITHUB_URL=`git config pr.github.url` if [ "$GITHUB_URL" == "" ]; then GITHUB_URL=https://github.com fi if [ "$MERGE_BRANCH" == "" ]; then set +e MERGE_BRANCH=`git config pr.defaultbranch` if [ "$MERGE_BRANCH" == "" ]; then MERGE_BRANCH=master fi set -e @@ -39,7 +45,7 @@ if [ "$REPO_NAME" == "" ]; then REPO_NAME=`git config remote.origin.url | sed -E 's/.*\/([^\/]*)\.git/\1/'` fi URL=$GITHUB_URL/$UPSTREAM_ORG_NAME/$REPO_NAME/pull/new/$MERGE_BRANCH...$ORIGIN_ORG_NAME:$LOCAL_BRANCH echo Opening $URL if [ "$BOX" == "Linux" ]; then -
spmason revised this gist
Dec 10, 2013 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -1,7 +1,7 @@ #!/usr/bin/env bash # GitHub "open PR" script # Add somewhere in your path, then opening a PR is as easy as typing `pr` on the branch you want to open a pull request for # # NOTES: # - If working from a fork, name your fork's remove "origin" and the main repo "upstream" -
spmason created this gist
Dec 10, 2013 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,52 @@ #!/usr/bin/env bash # GitHub "open PR" script # Add somewhere in your path, then opening a PR is as easy as typing `pr` on the branch you want to opena PR for # # NOTES: # - If working from a fork, name your fork's remove "origin" and the main repo "upstream" # - If the default branch is not "master", use `git config pr.defaultbranch <branch_name>` to tell this script the correct branch to use set -e LOCAL_BRANCH=`git branch | grep ^\* | sed 's/^* //'` MERGE_BRANCH=$1 BOX=`uname -s` git push origin $LOCAL_BRANCH ORIGIN_ORG_NAME=`git config remote.origin.url | sed -E 's/.*:(.*)\/.*/\1/'` UPSTREAM_ORG_NAME=`git config remote.upstream.url | sed -E 's/.*:(.*)\/.*/\1/'` REPO_NAME=`git config remote.upstream.url | sed -E 's/.*\/([^\/]*)\.git/\1/'` if [ "$MERGE_BRANCH" == "" ]; then set +e MERGE_BRANCH=`git config pr.defaultbranch 2> /dev/null` if [ "$0" != "0" -o "$REPO_NAME" == "" ]; then MERGE_BRANCH=master fi set -e fi if [ "$ORIGIN_ORG_NAME" == "" ]; then echo Cannot divine the origin organisation name. Ensure you have a remote called "origin" exit 1 fi if [ "$UPSTREAM_ORG_NAME" == "" ]; then UPSTREAM_ORG_NAME=$ORIGIN_ORG_NAME fi if [ "$REPO_NAME" == "" ]; then REPO_NAME=`git config remote.origin.url | sed -E 's/.*\/([^\/]*)\.git/\1/'` fi URL=https://github.com/$UPSTREAM_ORG_NAME/$REPO_NAME/pull/new/$MERGE_BRANCH...$ORIGIN_ORG_NAME:$LOCAL_BRANCH echo Opening $URL if [ "$BOX" == "Linux" ]; then xdg-open $URL > /dev/null elif [ "$BOX" == "Darwin" ]; then open $URL else echo Are you using Windows??? Come oooon! explorer.exe $URL fi