scmrepo 2.1.0__py3-none-any.whl → 2.1.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of scmrepo might be problematic. Click here for more details.

@@ -646,13 +646,13 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
646
646
  except KeyError as exc:
647
647
  raise SCMError(f"'{url}' is not a valid Git remote or URL") from exc
648
648
 
649
- parsed = urlparse(url)
650
- if parsed.scheme in ("git", "git+ssh", "ssh") or url.startswith("git@"):
651
- raise NotImplementedError
652
649
  if os.name == "nt" and url.startswith("file://"):
653
650
  url = url[len("file://") :]
654
-
655
- yield self.repo.remotes.create_anonymous(url)
651
+ remote = self.repo.remotes.create_anonymous(url)
652
+ parsed = urlparse(remote.url)
653
+ if parsed.scheme in ("git", "git+ssh", "ssh") or remote.url.startswith("git@"):
654
+ raise NotImplementedError
655
+ yield remote
656
656
 
657
657
  def fetch_refspecs(
658
658
  self,
@@ -11,6 +11,7 @@ from scmrepo.progress import GitProgressReporter
11
11
  if TYPE_CHECKING:
12
12
  from pygit2 import Oid
13
13
  from pygit2.credentials import Keypair, Username, UserPass
14
+ from pygit2.enums import CredentialType
14
15
 
15
16
  from scmrepo.progress import GitProgressEvent
16
17
 
@@ -45,16 +46,20 @@ class RemoteCallbacks(_RemoteCallbacks, AbstractContextManager):
45
46
  self.progress(string)
46
47
 
47
48
  def credentials(
48
- self, url: str, username_from_url: Optional[str], allowed_types: int
49
+ self,
50
+ url: str,
51
+ username_from_url: Optional[str],
52
+ allowed_types: "CredentialType",
49
53
  ) -> "_Pygit2Credential":
50
54
  from pygit2 import GitError, Passthrough
51
- from pygit2.credentials import GIT_CREDENTIAL_USERPASS_PLAINTEXT, UserPass
55
+ from pygit2.credentials import UserPass
56
+ from pygit2.enums import CredentialType
52
57
 
53
58
  if self._tried_credentials:
54
59
  raise GitError(f"authentication failed for '{url}'")
55
60
  self._tried_credentials = True
56
61
 
57
- if allowed_types & GIT_CREDENTIAL_USERPASS_PLAINTEXT:
62
+ if allowed_types & CredentialType.USERPASS_PLAINTEXT:
58
63
  try:
59
64
  if self._store_credentials:
60
65
  creds = self._store_credentials
scmrepo/git/lfs/client.py CHANGED
@@ -1,8 +1,7 @@
1
1
  import logging
2
- from collections.abc import Awaitable, Iterable
2
+ from collections.abc import Iterable
3
3
  from contextlib import AbstractContextManager
4
- from functools import wraps
5
- from typing import TYPE_CHECKING, Any, Callable, Optional
4
+ from typing import TYPE_CHECKING, Any, Optional
6
5
 
7
6
  import aiohttp
8
7
  from dvc_http import HTTPFileSystem
@@ -32,29 +31,6 @@ class _LFSFileSystem(HTTPFileSystem):
32
31
  return {}
33
32
 
34
33
 
35
- def _authed(f: Callable[..., Awaitable]):
36
- """Set credentials and retry the given coroutine if needed."""
37
-
38
- # pylint: disable=protected-access
39
- @wraps(f) # type: ignore[arg-type]
40
- async def wrapper(self, *args, **kwargs):
41
- try:
42
- return await f(self, *args, **kwargs)
43
- except aiohttp.ClientResponseError as exc:
44
- if exc.status != 401:
45
- raise
46
- session = await self._set_session()
47
- if session.auth:
48
- raise
49
- auth = self._get_auth()
50
- if auth is None:
51
- raise
52
- self._session._auth = auth
53
- return await f(self, *args, **kwargs)
54
-
55
- return wrapper
56
-
57
-
58
34
  class LFSClient(AbstractContextManager):
59
35
  """Naive read-only LFS HTTP client."""
60
36
 
@@ -112,7 +88,6 @@ class LFSClient(AbstractContextManager):
112
88
  async def _set_session(self) -> aiohttp.ClientSession:
113
89
  return await self.fs.fs.set_session()
114
90
 
115
- @_authed
116
91
  async def _batch_request(
117
92
  self,
118
93
  objects: Iterable[Pointer],
@@ -134,14 +109,30 @@ class LFSClient(AbstractContextManager):
134
109
  headers = dict(self.headers)
135
110
  headers["Accept"] = self.JSON_CONTENT_TYPE
136
111
  headers["Content-Type"] = self.JSON_CONTENT_TYPE
137
- async with session.post(
138
- url,
139
- headers=headers,
140
- json=body,
141
- ) as resp:
142
- return await resp.json()
143
-
144
- @_authed
112
+ try:
113
+ async with session.post(
114
+ url,
115
+ headers=headers,
116
+ json=body,
117
+ raise_for_status=True,
118
+ ) as resp:
119
+ data = await resp.json()
120
+ except aiohttp.ClientResponseError as exc:
121
+ if exc.status != 401:
122
+ raise
123
+ auth = self._get_auth()
124
+ if auth is None:
125
+ raise
126
+ async with session.post(
127
+ url,
128
+ auth=auth,
129
+ headers=headers,
130
+ json=body,
131
+ raise_for_status=True,
132
+ ) as resp:
133
+ data = await resp.json()
134
+ return data
135
+
145
136
  async def _download(
146
137
  self,
147
138
  storage: "LFSStorage",
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: scmrepo
3
- Version: 2.1.0
3
+ Version: 2.1.1
4
4
  Summary: scmrepo
5
5
  Author-email: Iterative <support@dvc.org>
6
6
  License: Apache-2.0
@@ -18,11 +18,11 @@ scmrepo/git/backend/gitpython.py,sha256=6L47iX1SmqfM04_Ghwd_DEHegOKewCLu-5MTkBZO
18
18
  scmrepo/git/backend/dulwich/__init__.py,sha256=aQeuLqdprJcxnk8Jkp4mlLXkLRzqMnUwiuA3wjf3_dA,34366
19
19
  scmrepo/git/backend/dulwich/asyncssh_vendor.py,sha256=OuZ_bWe5-LiZCIMwBRaX_uj03oEcrRgr1uf9i2Xv4Fk,11497
20
20
  scmrepo/git/backend/dulwich/client.py,sha256=bcDroljSvNz6s5WWv9UVvZHKkOJOVTK_zU7YCq62TN4,2360
21
- scmrepo/git/backend/pygit2/__init__.py,sha256=F96Pf3zlZWjNth9M8iT7z4tYQ_mRAtpzl7Hhsc7kBCo,36967
22
- scmrepo/git/backend/pygit2/callbacks.py,sha256=Vc-kITzxLAB2kWvZOF8xMzGnKtu9O2P9IxWKGBygckw,2656
21
+ scmrepo/git/backend/pygit2/__init__.py,sha256=tapIRAh--nzGUcVGijaMSal2ZPscab9c1mHdqiUIxBU,37004
22
+ scmrepo/git/backend/pygit2/callbacks.py,sha256=Ky4YmUPhv9xjU_44ypBYIcaVHJixzaGb6t9HIeUmBP4,2751
23
23
  scmrepo/git/backend/pygit2/filter.py,sha256=2NlWfQ7soXN1H7Es6-LctE74hpj3QKQTlYqXRH83VpM,2128
24
24
  scmrepo/git/lfs/__init__.py,sha256=at5blRIKnKpg_g5dLRDsGWBFi6SbucRlF_DX6aAkGtE,257
25
- scmrepo/git/lfs/client.py,sha256=EaRiaRTi8qxFSTRNYWzzhWysYiaC0l4dy1T8ED5D4CA,5582
25
+ scmrepo/git/lfs/client.py,sha256=MitdVwI_1_17qwMM-totHG3-qAt80oAkHiVTcLaYapY,5347
26
26
  scmrepo/git/lfs/exceptions.py,sha256=cLlImmPXWJJUl44S4xcRBa2T9wYRkWTaKQGwJylwOhA,77
27
27
  scmrepo/git/lfs/fetch.py,sha256=ADNpskbDrvMI7ru4AiOf_c1gfw8TQ7Wct0EiN2Pq-qc,4683
28
28
  scmrepo/git/lfs/object.py,sha256=rAYY_z9EYoHPfbpF1QHwL7ecYgaETPyCl-zBx0E1oIQ,337
@@ -30,8 +30,8 @@ scmrepo/git/lfs/pointer.py,sha256=BcVbtjoOUG9cEzyJSJDeweqehGZvq43P6NNLDYUGYEI,31
30
30
  scmrepo/git/lfs/progress.py,sha256=C-HGap81Gif_abhUIzQrM4lL4Tbq9I6C909A7zLTiOM,1726
31
31
  scmrepo/git/lfs/smudge.py,sha256=sMSatXCTHZ5cAo-gaE_6KXwCHlXGqzkF0dVgIbPwTJU,1563
32
32
  scmrepo/git/lfs/storage.py,sha256=FmdltddhyRg4jrCc1PaiC049_m8Ya9ELMikb-iOuvgw,2241
33
- scmrepo-2.1.0.dist-info/LICENSE,sha256=-1jhbPjoIVHR0cEgahL4Zhct75Ff4MzYCR_jOaJDPq8,11340
34
- scmrepo-2.1.0.dist-info/METADATA,sha256=nATZ36V-hq0_1THzLnlMmUIHnyAOXcxCPGJfuHOPPT0,4833
35
- scmrepo-2.1.0.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
36
- scmrepo-2.1.0.dist-info/top_level.txt,sha256=iunjod6w3GogERsAYfLRupnANXnqzX3jbIfbeIQG5cc,8
37
- scmrepo-2.1.0.dist-info/RECORD,,
33
+ scmrepo-2.1.1.dist-info/LICENSE,sha256=-1jhbPjoIVHR0cEgahL4Zhct75Ff4MzYCR_jOaJDPq8,11340
34
+ scmrepo-2.1.1.dist-info/METADATA,sha256=uAlODk9oF8tRBPOYX3Cv8r3DgJhjT0StqdJTQTr7PZM,4833
35
+ scmrepo-2.1.1.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
36
+ scmrepo-2.1.1.dist-info/top_level.txt,sha256=iunjod6w3GogERsAYfLRupnANXnqzX3jbIfbeIQG5cc,8
37
+ scmrepo-2.1.1.dist-info/RECORD,,