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

The pre-commit.protect-master should protect more than just master #8

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

lillialexis
Copy link
Member

@lillialexis lillialexis commented Nov 8, 2024

Summary:

Now it stops users from accidentally committing to main, a few other known branches (for mobile) and any of their target/deploy branches.

This can stop people from accidentally committing straight to a deploy branch, which 95% of the time, you never want to do. Can always just git commit -n if they reallllly need to get around it (But they never should!! security reasons!! committing directly to a deploy branch bypasses PRs!! They should use an audit if they have to...)

Issue: FEI-5966

Test plan:

  • See it fail when trying to commit on other branches, like main
  • Use OLC to add a target branch, then try and commit to it directly, see it fail

@lillialexis lillialexis self-assigned this Nov 8, 2024
if [ "`git rev-parse --abbrev-ref HEAD`" = "master" ]; then
echo "FATAL ERROR: You cannot commit directly to the master branch."
echo "Commit to a deploy branch instead:"
echo " https://khanacademy.org/r/git-at-ka"
Copy link
Member Author

Choose a reason for hiding this comment

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

this link went nowhere...

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.

Thank you for adding main! I don't know about deploy or next but they seem plausible to me.

Adding the deploy branches also makes a lot of sense. Hopefully that will avoid some tsuris.

for branch in $KNOWN_DEPLOY_BRANCHES; do
if [ "$CURRENT_BRANCH" = "$branch" ]; then
echo "FATAL ERROR: You cannot commit directly to the $CURRENT_BRANCH branch."
echo "Make a pull-request (or audit) and land it to this branch instead"
Copy link
Member

Choose a reason for hiding this comment

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

Maybe: "You cannot commit directly to the ... branch because you've told OLC it's a deploy branch." And also give instructions on how to tell OLC it's not a deploy branch, if that was in error.

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.

4 participants