Skip to content

Commit 885a03d

Browse files
committed
credentials: support aws-cli credential-helper
1 parent 12787b5 commit 885a03d

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/scmrepo/git/backend/dulwich/client.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ def _get_auth(self) -> Dict[str, str]:
6868
from urllib3.util import make_headers
6969

7070
try:
71-
creds = Credential(username=self._username, url=self._base_url).fill()
71+
base_url = self._base_url.rstrip("/")
72+
creds = Credential(username=self._username, url=base_url).fill()
7273
self._store_credentials = creds
7374
return make_headers(basic_auth=f"{creds.username}:{creds.password}")
7475
except CredentialNotFoundError:

src/scmrepo/git/credentials.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -176,9 +176,9 @@ def get(self, credential: "Credential", **kwargs) -> "Credential":
176176
logger.debug(res.stderr)
177177

178178
credentials = {}
179-
for line in res.stdout.strip().splitlines():
179+
for line in res.stdout.splitlines():
180180
try:
181-
key, value = line.split("=")
181+
key, value = line.split("=", maxsplit=1)
182182
credentials[key] = value
183183
except ValueError:
184184
continue
@@ -399,7 +399,8 @@ def _get_interactive(
399399

400400
def store(self, credential: "Credential", **kwargs):
401401
"""Store the credential, if applicable to the helper"""
402-
self[credential] = credential
402+
if credential.protocol or credential.host or credential.path:
403+
self[credential] = credential
403404

404405
def erase(self, credential: "Credential", **kwargs):
405406
"""Remove a matching credential, if any, from the helper’s storage"""
@@ -514,7 +515,7 @@ def __init__(
514515
self.username = self.username or parsed.username
515516
self.password = self.password or parsed.password
516517
if parsed.path:
517-
self.path = self.path or parsed.path
518+
self.path = self.path or parsed.path.lstrip("/")
518519

519520
def __getitem__(self, key: object) -> str:
520521
if isinstance(key, str):

0 commit comments

Comments
 (0)