Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add push git tools #29

wants to merge 1 commit into from

Conversation

raipatti
Copy link

  • Assert sync
  • Push production
  • Push staging

- Assert sync
- Push production
- Push staging
@raipatti raipatti requested a review from esamattis March 22, 2024 10:02
echo "You can deploy to production only from the local master branch"
exit 1
fi

Copy link
Member

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.

Suggested change
if [ "$(git status --porcelain)" != "" ]; then
echo "Dirty. Commit changes before deploy"
exit 1
fi

Comment on lines +8 to +13
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
Copy link
Member

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".

Suggested change
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

Copy link
Member

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"
Copy link
Member

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.

Suggested change
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)"

Copy link
Member

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants