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

Don't stop user from committing merge commits to deploy branches #9

Open
wants to merge 4 commits into
base: FEI-5966
Choose a base branch
from

Conversation

lillialexis
Copy link
Member

Summary:

If I'm bringing in master or main 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

@lillialexis lillialexis self-assigned this Nov 13, 2024
@lillialexis lillialexis requested a review from a team November 13, 2024 00:35
@lillialexis lillialexis marked this pull request as draft November 13, 2024 00:53
esac

# Exit if it's a merge commit
if [ "$(git rev-list --parents -n 1 HEAD | wc -w)" -gt 2 ]; then
Copy link
Member

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?

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

@csilvers csilvers left a 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.

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I cleaned it up 😄

@lillialexis lillialexis marked this pull request as ready for review November 13, 2024 01:03
Copy link
Member

@csilvers csilvers left a 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
Copy link
Member

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?

Comment on lines +31 to +39
# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# 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*)
Copy link
Member

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.

Copy link
Member Author

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!

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