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

feat: Add support for hasconfig git rule.#2075

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

Conversation

bvanelli
Copy link
Contributor

Support adding custom paths for the following git config:

# Anonymous user override[includeIf "hasconfig:remote.*.url:**/**github.com*/**"]path = ~/.personal.gitconfig

According to the documentation:

As for the naming of this keyword, it is for forwards compatibility with a naming scheme that supports more variable-based include conditions, but currently Git only supports the exact keyword described above.

So I have matched the condition exactly word to word withhasconfig:remote.*.url. I then go over the list of remotes and find usingfnmatchcase the correct remote (not sure iffnmatch.

Maybe a list of open points here:

  • I'm not sure if the wildcard format and the fnmatch function are equivalent. Is it necessary to match these two 100%? Maybe a maintainer would have more experience with
  • Should I write more test cases?
  • Write a couple of cases which are handled by both git binary and gitpython and compare the two.

Closes#2017

Copy link
Member

@ByronByron left a comment

Choose a reason for hiding this comment

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

Thanks so much for contributing this capability!

I really like the implementation, and love that there are tests as well.
To my mind these tests cover the most important cases.

Good to merge!


elifkeyword=="hasconfig:remote.*.url":
forremoteinself._repo.remotes:
iffnmatch.fnmatchcase(remote.url,value):
Copy link
Member

Choose a reason for hiding this comment

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

Using a case-sensitive search is correct here, Git does the same.


# Ensure that config with hasconfig and incorrect url is incorrect.
withopen(path1,"w")asstream:
stream.write(template.format("incorrect",path2))
Copy link
Member

Choose a reason for hiding this comment

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

I think that "incorrect" fails to communicate that this is a URL that simply doesn't match.
Maybe something for a follow-up.

@ByronByron merged commit0c2bfac intogitpython-developers:mainOct 8, 2025
27 checks passed
@bvanellibvanelli deleted the 2017-support-hasconfig-remote-url branchOctober 8, 2025 05:35
@bvanelli
Copy link
ContributorAuthor

Oh, such speed, thanks for the quick response!

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

Reviewers

@ByronByronByron approved these changes

Assignees

No one assigned

Labels

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

hasconfig:remote.*.url not supported by includeIf

2 participants

@bvanelli@Byron

[8]ページ先頭

©2009-2025 Movatter.jp