Skip to content

Instantly share code, notes, and snippets.

@davidfurlong
Last active December 22, 2021 12:20
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 davidfurlong/4b90ee700b21c145a57d1021180c9062 to your computer and use it in GitHub Desktop.
Save davidfurlong/4b90ee700b21c145a57d1021180c9062 to your computer and use it in GitHub Desktop.
Interactive bash script to create a branch, commit, push, open a pull request on github, and request review with current changes. For the time-conscious devs out there. Use as `sh patch.sh`
#!/bin/bash
# To use, run `sh patch.sh`.
# This is useful for small changes like a typo or translation but not recommended when you may have unwanted changes in your git filesystem
# Assumes your base branch is called dev and that you want to request a review from DeedMob/engineering
# Optional step we use
npm run lint-staged
# Will prefix the branch with chore/ fix/ or feat/ as well as the commit
read -p "Type (ex fix, chore, feat): " prtype
# Will populate the commit message as well as use this value to generate the branch name
read -p "When merged, this commit will ($prtype): " msg
# Populate the Pull request description
read -p "Add a description and link to asana: " description
# Create a valid and informative branch name
branchname=$(echo "$prtype/${msg//[ \/]/-}" | tr '[:upper:]' '[:lower:]' | tr -cd '[:alnum:]/-')
echo "creating branch $branchname"
git checkout -b "$branchname" &&
git add ./ &&
git commit -m "$prtype: $msg" &&
# Create a pull request, replace this with your organization to request review
hub pull-request -p -r DeedMob/engineering -F- <<<"$prtype: $msg
$description" &&
git checkout dev &&
echo "Successfully commited, opened PR for branch $branchname and switched back to dev"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment