Skip to content

Instantly share code, notes, and snippets.

@simonewebdesign
Created August 31, 2017 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save simonewebdesign/811b012ee78392c5590acf9d76bdb744 to your computer and use it in GitHub Desktop.
Save simonewebdesign/811b012ee78392c5590acf9d76bdb744 to your computer and use it in GitHub Desktop.
Fish shell function to open a pull request on BitBucket
# 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