Last active
December 22, 2021 12:20
-
-
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`
This file contains hidden or 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
#!/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