Last active
August 29, 2015 14:20
-
-
Save benekastah/f7420c74ffe6e68bb280 to your computer and use it in GitHub Desktop.
Git babysit - remind yourself to do the things you always forget before pushing
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
| [alias] | |
| babysit = !git-babysit |
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
| #!/usr/bin/env bash | |
| this-branch() { | |
| git rev-parse --abbrev-ref HEAD | |
| } | |
| list-item() { | |
| echo "$1 (y/n/d) " | |
| read yn | |
| case "$yn" in | |
| y|Y|yes) | |
| ;; | |
| n|N|q|Q|no) | |
| exit 1 | |
| ;; | |
| d|D) | |
| git diff origin/master...HEAD | |
| list-item "$1" | |
| ;; | |
| *) | |
| echo "Invalid response: $yn" | |
| list-item "$1" | |
| ;; | |
| esac | |
| } | |
| show-checklist() { | |
| list-item 'Did you thoroughly fix the entire problem?' | |
| list-item 'Is this the simplest/smallest set of changes that can be made?' | |
| list-item 'Can you say there no areas that need further comments?' | |
| list-item 'Where possible, did you remove comments by making the code clearer?' | |
| list-item 'Have you assessed the risk these changes pose and explored less risky options?' | |
| list-item 'Did you list out potential edge cases and test them?' | |
| list-item 'Have you thoroughly tested all branches of your code?' | |
| list-item 'Have you written tests where necessary?' | |
| list-item 'Have you run the tests?' | |
| push_cmd="git push -u origin \"$(this-branch)\"" | |
| list-item "Automatically push ($push_cmd)?" | |
| eval "$push_cmd" | |
| } | |
| show-checklist |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's the workflow I use with this:
git babysit. Uncommitted changes don't show up in the diff ingit babysitso ensure all the things you want to push are already committed for best results.git babysitwill offer to push for you.