pFad - Phone/Frame/Anonymizer/Declutterfier! Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

URL: http://github.com/pre-commit/pre-commit-hooks/pull/1245

="https://github.githubassets.com/assets/actions-0e714a98ea09295a.css" /> no-commit-to-branch: Auto-detect repository's default branch by emanb29 · Pull Request #1245 · pre-commit/pre-commit-hooks · GitHub
Skip to content

no-commit-to-branch: Auto-detect repository's default branch#1245

Closed
emanb29 wants to merge 2 commits intopre-commit:mainfrom
emanb29:feature/auto-detect-main-branch
Closed

no-commit-to-branch: Auto-detect repository's default branch#1245
emanb29 wants to merge 2 commits intopre-commit:mainfrom
emanb29:feature/auto-detect-main-branch

Conversation

@emanb29
Copy link
Copy Markdown

@emanb29 emanb29 commented Apr 4, 2026

Many repos I work on use dev or develop for the trunk branch -- it'd be convenient for those to be protected as defaults. However, others may well use dev as an intentionally-volatile branch. Instead of guessing, we can infer the default branch by inspecting origen/HEAD. If that fails for whatever reason, fall back to the previous default of master+main

Comment on lines -155 to +157
Both `main` and `master` are protected by default if no branch argument is set.
If no branch argument is set, the hook auto-detects the repository's default
branch from `origen/HEAD`. Falls back to protecting both `main` and `master`
if `origen/HEAD` is not configured.
Copy link
Copy Markdown
Member

@asottile asottile Apr 5, 2026

Choose a reason for hiding this comment

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

as written this is a breaking change

please in the future discuss feature ideas before wasting time on implementation such that we can find the problems during the design phase rather than at the last mile of the coding phase

I suspect if this is going to be accepted at all this would need to be a separate option rather than an implicit behaviour -- especially because as written it is an inconsistent implicit behaviour (based on the repository state)

and with a required option to trigger this behaviour -- I kinda see little point to the option at all (since you could just specify the option that's already there with the proper value instead and accomplish the same thing)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

It's theoretically a breaking change, but not practically. I suspect anyone relying on the default is doing so because of an intent to protect their trunk branch.

As for the process quibble: the greater waste would have been a discussion -- I needed this behavior, now I have a fork with it. An unexpected 9-line PR isn't dropping a huge amount of work on you and other maintainers without any notice, so I decided to offer it to the community for a tool I've found generally delightful to use rather than keeping it in an isolated fork.

You're welcome to take the change, reject it, or modify it to your liking. Consider this PR a notice of interest from a community member and an offer to save you some work in the case your philosophy as a maintainer aligns with mine as a user.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

pFad - Phonifier reborn

Pfad - The Proxy pFad © 2024 Your Company Name. All rights reserved.





Check this box to remove all script contents from the fetched content.



Check this box to remove all images from the fetched content.


Check this box to remove all CSS styles from the fetched content.


Check this box to keep images inefficiently compressed and original size.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy