-
-
Save eliranmal/fee365b2b416fe9ac0ab55b3fa1a75df to your computer and use it in GitHub Desktop.
Bash script to make a pull request from the current git repository.
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 | |
pull_request() { | |
local to_branch="$1" | |
if [ -z $to_branch ]; then | |
to_branch="master" | |
fi | |
local access_token="[some access token with lots of characters]" | |
local root_endpoint="https://api.github.com" | |
local origin="$(git config --get remote.origin.url)" | |
local user="$(echo "$origin" | sed -e 's/.*[\/:]\([^/]*\)\/[^/]*$/\1/')" | |
local repo="$(basename `git rev-parse --show-toplevel`)" | |
local from_branch="$(git rev-parse --abbrev-ref HEAD)" | |
curl -i \ | |
-H 'Authorization: token '"$access_token" \ | |
-H 'Accept: application/vnd.github.v3+json' \ | |
-d '{ | |
"title": "Amazing new feature", | |
"body": "Please pull this in!", | |
"head": "'"$from_branch"'", | |
"base": "'"$to_branch"'" | |
}' \ | |
-L https://"$root_endpoint"/repos/"$user"/"$repo"/pulls | |
} | |
pull_request "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment