Created
August 31, 2021 17:36
-
-
Save kokizzu/7d7448bac074a7fe341440661886a646 to your computer and use it in GitHub Desktop.
PullPush: shortcut for add, commit, pull, push
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
#!/usr/bin/env bash | |
if [ $# -eq 0 ] ; then | |
echo "Usage: | |
./pullpush.sh 'the commit message'" | |
exit | |
fi | |
# format indentation | |
gofmt -s -w . # go fmt `find . -name '*.go' -type f` | |
echo "codes formatted.." | |
# testing if has error | |
go build -o /tmp/dummy *.go || ( echo 'has error, exiting..' ; kill 0 ) | |
echo "codes tested.." | |
# add and commit all files | |
git add . | |
git status | |
read -p "Press Ctrl+C to exit, press any enter key to check the diff.. | |
" | |
# recheck again | |
git diff --staged | |
echo 'Going to commit with message: '\"$*\" | |
read -p "Press Ctrl+C to exit, press any enter key to really commit.. | |
" | |
if git commit -m "$*" ; then | |
BRANCH=`git branch --show-current` | |
if [ -e .git/refs/remotes/origin/$BRANCH ]; then | |
git pull origin $BRANCH && git push | |
else | |
git push --set-upstream origin $BRANCH | |
fi | |
else | |
echo "failed commit: $*" | |
fi | |
#git tag -a `ruby -e 't = Time.now; print "v1.#{t.month+(t.year-2021)*12}%02d.#{t.hour}%02d" % [t.day, t.min]'` -m "$*" | |
#git push --tags | |
# delete tag: | |
# git tag -d v1.mdd.hhmm | |
# git push -d origin v1.mdd.hhmm |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment