Skip to content

Instantly share code, notes, and snippets.

@ultim8k
Created July 30, 2018 14:04
Show Gist options
  • Save ultim8k/e6ef2354e54cc7d3e1aeb14300fec1fb to your computer and use it in GitHub Desktop.
Save ultim8k/e6ef2354e54cc7d3e1aeb14300fec1fb to your computer and use it in GitHub Desktop.
Get url for pull request to current repo's remote origin
function get_pull_request_url () {
local GIT_BRANCH_NAME=$(git symbolic-ref --short HEAD);
local GIT_REMOTE_URL=$(git config --get remote.origin.url);
# [email protected]:USER_NAME/REPO_NAME.git
local GIT_FULL_REMOTE_NAME=$(echo $GIT_REMOTE_URL | sed -e 's/[email protected]://' -e 's/\.git//');
# https://github.com/ORG_NAME/REPO_NAME/compare/GIT_BRANCH_NAME?expand=1
echo "https://github.com/${GIT_FULL_REMOTE_NAME}/compare/${GIT_BRANCH_NAME}?expand=1"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment