Created
August 31, 2017 13:26
-
-
Save simonewebdesign/811b012ee78392c5590acf9d76bdb744 to your computer and use it in GitHub Desktop.
Fish shell function to open a pull request on BitBucket
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
# fill the dots with proper information | |
function open_pr | |
set commit_info (git log -1 --pretty=%B) | |
set title (echo $commit_info | sed -n '1p') | |
set description (echo $commit_info | tail -n +3 | sed -E ':a;N;$!ba;s/\r{0,1}\n/ \\n/g') | |
set source_branch (git rev-parse --abbrev-ref HEAD) | |
set destination_branch develop | |
set repo_full_name "foo/bar" | |
set reviewers "[ { \"username\": \"someusername\" }, ... ]" | |
set username ... | |
set password ... | |
curl -X POST \ | |
-H "Content-Type: application/json" \ | |
-u $username:$password \ | |
https://bitbucket.org/api/2.0/repositories/$repo_full_name/pullrequests \ | |
-d "{ \"title\": \"$title\", \"description\": \"$description\", \"source\": { \"branch\": { \"name\": \"$source_branch\" }, \"repository\": { \"full_name\": \"$repo_full_name\" } }, \"destination\": { \"branch\": { \"name\": \"$destination_branch\" } }, \"reviewers\": $reviewers, \"close_source_branch\": true }" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment