-
Notifications
You must be signed in to change notification settings - Fork 4
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
Don't stop user from committing merge commits to deploy branches #9
base: FEI-5966
Are you sure you want to change the base?
Conversation
templates/pre-commit.protect-master
Outdated
esac | ||
|
||
# Exit if it's a merge commit | ||
if [ "$(git rev-list --parents -n 1 HEAD | wc -w)" -gt 2 ]; then |
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.
Shouldn't it be -gt 1
?
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.
Oh, I see, it emits two shas for each parent, so this is right as you have it. Don't mind me.
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.
Turns out this was wrong anyway, because we need to look at the commit in the middle of being made, so I changed it.
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.
Makes sense to me! I see it's still in draft so I'll wait to approve until you're ready for review.
templates/pre-commit.protect-master
Outdated
if [ "$(git rev-list --parents -n 1 HEAD | wc -w)" -gt 2 ]; then | ||
exit 0 | ||
fi | ||
|
||
# Get the known deploy branches from the git config (comma-separated list) | ||
KNOWN_DEPLOY_BRANCHES=$(git config --get ka.olc.targetBranches) |
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.
Just a style thing, but I'd move this down after line 46, so that the two cannot-commit checks are together.
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.
I cleaned it up 😄
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.
Fine by me! I only care about main
/master
, so I'm happy with you doing whatever you think makes sense, for deploy
/next
.
exit 0 | ||
fi | ||
|
||
# Check if we are in the middle of a rebase |
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.
I didn't think we wanted to let folks rebase deploy branches?
# Check if we are in the middle of a merge | ||
if [ -f ".git/MERGE_HEAD" ]; then | ||
exit 0 | ||
fi | ||
|
||
# Check if we are in the middle of a rebase | ||
if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then | ||
exit 0 | ||
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.
# Check if we are in the middle of a merge | |
if [ -f ".git/MERGE_HEAD" ]; then | |
exit 0 | |
fi | |
# Check if we are in the middle of a rebase | |
if [ -d ".git/rebase-merge" ] || [ -d ".git/rebase-apply" ]; then | |
exit 0 | |
fi | |
# Check if we are in the middle of a merge or rebase. | |
if [ -f ".git/MERGE_HEAD" -o -d ".git/rebase-merge" -o -d ".git/rebase-apply" ]; then | |
exit 0 | |
fi |
(Just a small simplification, it's fine as-is too.)
case "$CURRENT_BRANCH" in | ||
master|main|next|deploy*) | ||
next|deploy*) |
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.
Actually, I'm not really comfortable with deploy*
here. I have non-deploy branches with names like deploy-fastly-fix
, for fixes to the deploy-fastly script. It's fine when OLC gets concerned with that and I can override it, but having a pre-commit hook get concerned with it isn't ok. So I'd just take that out, or rename it to just deploy
.
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.
ok, I'll change it!
Summary:
If I'm bringing in
master
ormain
and there's a merge conflict, I want to commit without using-n
, because I want the rest of the verification things to happen.Issue: FEI-5966
Test plan:
Set up a lot of test branches and different combos of things, and test all cases