Skip to content

Commit d23abb3

Browse files
danchevWauplin
andauthored
Improve Git Credential Helper Detection for Linux (GCM & libsecret support) (#3264)
* feat: add support for Git Credential Manager (GCM) - Update GIT_CREDENTIAL_REGEX to match git-credential-manager - Add tests to verify GCM is recognized and handled Ref: https://git-scm.com/doc/credential-helpers * feat: support for git-credential-libsecret in credential helper detection - Extend GIT_CREDENTIAL_REGEX to recognize git-credential-libsecret, enabling integration with Secret Service-compatible keyrings (e.g., GNOME Keyring, KDE Wallet) on Linux. - Add unit tests to validate detection and handling of git-credential-libsecret Ref: https://git-scm.com/doc/credential-helpers --------- Co-authored-by: Lucain <[email protected]>
1 parent d5249b7 commit d23abb3

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/huggingface_hub/utils/_git_credential.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
^\s* # start of line
2828
credential\.helper # credential.helper value
2929
\s*=\s* # separator
30-
(\w+) # the helper name (group 1)
30+
([\w\-\/]+) # the helper name or absolute path (group 1)
3131
(\s|$) # whitespace or end of line
3232
""",
3333
flags=re.MULTILINE | re.IGNORECASE | re.VERBOSE,

tests/test_utils_git_credentials.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
[credential]
1919
helper = store
2020
helper = cache --timeout 30000
21+
helper = git-credential-manager
22+
helper = /usr/libexec/git-core/git-credential-libsecret
2123
"""
2224

2325

@@ -38,6 +40,8 @@ def test_list_credential_helpers(self) -> None:
3840
helpers = list_credential_helpers(folder=self.cache_dir)
3941
self.assertIn("cache", helpers)
4042
self.assertIn("store", helpers)
43+
self.assertIn("git-credential-manager", helpers)
44+
self.assertIn("/usr/libexec/git-core/git-credential-libsecret", helpers)
4145

4246
def test_set_and_unset_git_credential(self) -> None:
4347
username = "hf_test_user_" + str(round(time.time())) # make username unique

0 commit comments

Comments
 (0)