Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
Lee-W wants to merge4 commits intomaster
base:master
Choose a base branch
Loading
fromadd-check-against-main-branch-hook

Conversation

Lee-W
Copy link
Member

Description

Checklist

  • Add test cases to all the changes you introduce
  • Runpoetry all locally to ensure this change passes linter check and test
  • Test the changes on the local machine manually
  • Update the documentation for the changes

Expected behavior

Steps to Test This Pull Request

Additional context

@codecovCodecov
Copy link

codecovbot commentedMay 6, 2025
edited
Loading

Codecov Report

Attention: Patch coverage is66.66667% with4 lines in your changes missing coverage. Please review.

Project coverage is 97.40%. Comparing base(120d514) to head(5fafc37).
Report is 592 commits behind head on master.

Files with missing linesPatch %Lines
commitizen/git.py20.00%4 Missing⚠️
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
FlagCoverage Δ
unittests97.40% <66.66%> (+0.06%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report?Share it here.

🚀 New features to boost your workflow:
  • ❄️Test Analytics: Detect flaky tests, report on failures, and find test suite problems.



def guess_default_branch() -> str:
c = cmd.run("git branch --format '%(refname:short)' --list master main")
Copy link
Member

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 bemaster ormain so it won't work withdevelop which is common, or any other "exotic choice".

To handle this, I usegit 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. Thehead is for the case where there are multiple remotes, but makes the hypothesis that they share the same default branch.

Copy link
MemberAuthor

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 setdefault_git_remote anddefault_git_branch_name (but not yet have time to impletemtn it 🥲)

Copy link
Member

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 👍🏼

@@ -92,7 +90,8 @@ def __call__(self):
)
out.success("Commit validation: successful!")

def _get_commits(self):
def _get_commits(self) -> list[git.GitCommit]:
# TODO: this method seems to do a few different things. probably would be better if we could split it to smaller functions
Copy link
Contributor

Choose a reason for hiding this comment

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

Already done in refactors branch

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

@noirbizarrenoirbizarrenoirbizarre left review comments

@bearomorphismbearomorphismbearomorphism left review comments

@woilewoileAwaiting requested review from woilewoile will be requested when the pull request is marked ready for reviewwoile is a code owner

At least 1 approving review is required to merge this pull request.

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@Lee-W@noirbizarre@bearomorphism

[8]ページ先頭

©2009-2025 Movatter.jp