-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add push git tools #29
base: master
Are you sure you want to change the base?
Conversation
raipatti
commented
Mar 22, 2024
- Assert sync
- Push production
- Push staging
- Assert sync - Push production - Push staging
echo "You can deploy to production only from the local master branch" | ||
exit 1 | ||
fi | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncommitted changes are not deployed. Usually it is not intentional to leave changes not deployed. If user really wants this they can manually stash them.
if [ "$(git status --porcelain)" != "" ]; then | |
echo "Dirty. Commit changes before deploy" | |
exit 1 | |
fi | |
git push origin $branch:$branch | ||
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/$branch)" ]; then | ||
echo "You local git is not sync with the remote origin/$branch" | ||
echo "Ensure it is synced with: git pull origin && git push origin" | ||
exit 1 | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks off. After push it is alway sync and the assert cannot ever fail
I'd consider adding a dirty check here too since uncommitted changes cannot be in "sync".
git push origin $branch:$branch | |
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/$branch)" ]; then | |
echo "You local git is not sync with the remote origin/$branch" | |
echo "Ensure it is synced with: git pull origin && git push origin" | |
exit 1 | |
fi | |
if [ "$(git status --porcelain)" != "" ]; then | |
echo "Dirty git." | |
exit 1 | |
fi | |
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/$branch)" ]; then | |
echo "You local git is not sync with the remote origin/$branch" | |
echo "Ensure it is synced with: git pull origin && git push origin" | |
exit 1 | |
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also mutating the origin in an "assert" is bit surprising
set -o pipefail | ||
|
||
if [ "$(git rev-parse --abbrev-ref HEAD)" != "master" ]; then | ||
echo "You can deploy to production only from the local master branch" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Usually error messages (this and others) should be logged to stderr so piping would not hide them. We probably won't be piping these probably does not matter.
echo "You can deploy to production only from the local master branch" | |
>&2 echo "You can deploy to production only from the local master branch" |
|
||
# find out on which branch were are on | ||
branch="$(git rev-parse --abbrev-ref HEAD)" | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
git dirty check here too?