FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

feat: Add support for hasconfig git rule. by bvanelli · Pull Request #2075 · gitpython-developers/GitPython · GitHub

Repository navigation

feat: Add support for hasconfig git rule. - #2075

Merged
Byron merged 2 commits into
gitpython-developers:mainfrom
bvanelli:2017-support-hasconfig-remote-url
Oct 8, 2025
Merged

Byron merged 2 commits into
gitpython-developers:mainfrom
bvanelli:2017-support-hasconfig-remote-url

Conversation

bvanelli commented Oct 7, 2025

Copy link
Copy Markdown
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 with hasconfig:remote.*.url. I then go over the list of remotes and find using fnmatchcase the correct remote (not sure if fnmatch.

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

Byron left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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!

Comment thread git/config.py

elif keyword == "hasconfig:remote.*.url":
for remote in self._repo.remotes:
if fnmatch.fnmatchcase(remote.url, value):

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Comment thread test/test_config.py

# Ensure that config with hasconfig and incorrect url is incorrect.
with open(path1, "w") as stream:
stream.write(template.format("incorrect", path2))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Byron merged commit 0c2bfac into gitpython-developers:main Oct 8, 2025
27 checks passed
bvanelli deleted the 2017-support-hasconfig-remote-url branch October 8, 2025 05:35

bvanelli commented Oct 8, 2025

Copy link
Copy Markdown
Contributor Author

Oh, such speed, thanks for the quick response!

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

hasconfig:remote.*.url not supported by includeIf

2 participants


Back | FazBrowse Home | New Git URL