-
-
Notifications
You must be signed in to change notification settings - Fork 282
Add check against main branch hook #1400
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
base: master
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1400 +/- ##
==========================================
+ Coverage 97.33% 97.40% +0.06%
==========================================
Files 42 57 +15
Lines 2104 2661 +557
==========================================
+ Hits 2048 2592 +544
- Misses 56 69 +13
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
||
|
||
def guess_default_branch() -> str: | ||
c = cmd.run("git branch --format '%(refname:short)' --list master main") |
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.
This makes a strong hypothesis that the reference branch can only be master
or main
so it won't work with develop
which is common, or any other "exotic choice".
To handle this, I use git branch -r | grep -Po "HEAD -> .+/\K.+$" | head -n 1
which works with any default branch as long as there is a remote with a default. The head
is for the case where there are multiple remotes, but makes the hypothesis that they share the same default branch.
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 guess I'll have to try those commands 👀 Looks interesting!
I'm thinking of letting users set default_git_remote
and default_git_branch_name
(but not yet have time to impletemtn 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.
Yes, that's a good idea. Having guess the default but keeping the possibility to explicitly set it from the configuration 👍🏼
Description
Checklist
poetry all
locally to ensure this change passes linter check and testExpected behavior
Steps to Test This Pull Request
Additional context