scmrepo 3.3.3__tar.gz → 3.3.5__tar.gz
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.
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.pre-commit-config.yaml +1 -1
- {scmrepo-3.3.3/src/scmrepo.egg-info → scmrepo-3.3.5}/PKG-INFO +1 -1
- {scmrepo-3.3.3 → scmrepo-3.3.5}/noxfile.py +1 -1
- {scmrepo-3.3.3 → scmrepo-3.3.5}/pyproject.toml +6 -4
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/pygit2/__init__.py +67 -87
- {scmrepo-3.3.3 → scmrepo-3.3.5/src/scmrepo.egg-info}/PKG-INFO +1 -1
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.coveragerc +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.cruft.json +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.gitattributes +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.github/dependabot.yml +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.github/workflows/release.yaml +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.github/workflows/tests.yaml +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.github/workflows/update-template.yaml +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/.gitignore +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/CODE_OF_CONDUCT.rst +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/CONTRIBUTING.rst +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/LICENSE +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/README.rst +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/setup.cfg +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/asyn.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/base.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/exceptions.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/fs.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/base.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/dulwich/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/dulwich/asyncssh_vendor.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/dulwich/client.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/gitpython.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/pygit2/callbacks.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/backend/pygit2/filter.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/config.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/credentials.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/client.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/exceptions.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/fetch.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/object.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/pointer.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/progress.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/smudge.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/lfs/storage.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/objects.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/git/stash.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/noscm.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/progress.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/py.typed +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/urls.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo/utils.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo.egg-info/SOURCES.txt +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo.egg-info/dependency_links.txt +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo.egg-info/requires.txt +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/src/scmrepo.egg-info/top_level.txt +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/conftest.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/docker-compose.yml +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/git-init/git.sh +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_credentials.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_dulwich.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_fs.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_git.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_lfs.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_noscm.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_pygit2.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_scmrepo.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_stash.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/test_urls.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/user.key +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/user.key.pub +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/vendor/__init__.py +0 -0
- {scmrepo-3.3.3 → scmrepo-3.3.5}/tests/vendor/test_paramiko_vendor.py +0 -0
|
@@ -37,7 +37,7 @@ def safety(session: nox.Session) -> None:
|
|
|
37
37
|
"""Scan dependencies for insecure packages."""
|
|
38
38
|
session.install(".[dev]")
|
|
39
39
|
session.install("safety")
|
|
40
|
-
session.run("safety", "check", "--full-report")
|
|
40
|
+
session.run("safety", "check", "--full-report", "--ignore=67599")
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
@nox.session
|
|
@@ -125,6 +125,10 @@ ignore_missing_imports = true
|
|
|
125
125
|
ignore-words-list = "cachable, keypair"
|
|
126
126
|
|
|
127
127
|
[tool.ruff]
|
|
128
|
+
output-format = "full"
|
|
129
|
+
show-fixes = true
|
|
130
|
+
|
|
131
|
+
[tool.ruff.lint]
|
|
128
132
|
ignore = [
|
|
129
133
|
"S101", # assert
|
|
130
134
|
"PLR2004", # magic-value-comparison
|
|
@@ -180,10 +184,8 @@ select = [
|
|
|
180
184
|
"W", # pycodestyle - Warning
|
|
181
185
|
"YTT", # flake8-2020
|
|
182
186
|
]
|
|
183
|
-
show-source = true
|
|
184
|
-
show-fixes = true
|
|
185
187
|
|
|
186
|
-
[tool.ruff.per-file-ignores]
|
|
188
|
+
[tool.ruff.lint.per-file-ignores]
|
|
187
189
|
"noxfile.py" = ["D", "PTH"]
|
|
188
190
|
"tests/**" = ["S", "ARG001", "ARG002", "ANN"]
|
|
189
191
|
"docs/**" = ["INP"]
|
|
@@ -199,5 +201,5 @@ strict = true
|
|
|
199
201
|
[tool.ruff.lint.isort]
|
|
200
202
|
known-first-party = ["scmrepo"]
|
|
201
203
|
|
|
202
|
-
[tool.ruff.pylint]
|
|
204
|
+
[tool.ruff.lint.pylint]
|
|
203
205
|
max-args = 10
|
|
@@ -34,6 +34,7 @@ logger = logging.getLogger(__name__)
|
|
|
34
34
|
if TYPE_CHECKING:
|
|
35
35
|
from pygit2 import Commit, Oid, Signature
|
|
36
36
|
from pygit2.config import Config as _Pygit2Config
|
|
37
|
+
from pygit2.enums import CheckoutStrategy
|
|
37
38
|
from pygit2.remotes import Remote
|
|
38
39
|
from pygit2.repository import Repository
|
|
39
40
|
|
|
@@ -72,7 +73,7 @@ class Pygit2Object(GitObject):
|
|
|
72
73
|
path = "/".join(key)
|
|
73
74
|
blob_kwargs = {
|
|
74
75
|
"as_path": path,
|
|
75
|
-
"commit_id": commit.
|
|
76
|
+
"commit_id": commit.id,
|
|
76
77
|
}
|
|
77
78
|
blobio = BlobIO(self.obj, **blob_kwargs)
|
|
78
79
|
if mode == "rb":
|
|
@@ -108,7 +109,7 @@ class Pygit2Object(GitObject):
|
|
|
108
109
|
|
|
109
110
|
@property
|
|
110
111
|
def sha(self) -> str:
|
|
111
|
-
return self.obj.
|
|
112
|
+
return str(self.obj.id)
|
|
112
113
|
|
|
113
114
|
def scandir(self) -> Iterable["Pygit2Object"]:
|
|
114
115
|
for entry in self.obj:
|
|
@@ -190,12 +191,13 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
190
191
|
return RefdbFsBackend(self.repo)
|
|
191
192
|
|
|
192
193
|
def _resolve_refish(self, refish: str):
|
|
193
|
-
from pygit2 import
|
|
194
|
+
from pygit2 import Tag
|
|
195
|
+
from pygit2.enums import ObjectType
|
|
194
196
|
|
|
195
197
|
commit, ref = self.repo.resolve_refish(refish)
|
|
196
198
|
if isinstance(commit, Tag):
|
|
197
199
|
ref = commit
|
|
198
|
-
commit = commit.peel(
|
|
200
|
+
commit = commit.peel(ObjectType.COMMIT)
|
|
199
201
|
return commit, ref
|
|
200
202
|
|
|
201
203
|
@property
|
|
@@ -245,17 +247,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
245
247
|
)
|
|
246
248
|
|
|
247
249
|
@staticmethod
|
|
248
|
-
def _get_checkout_strategy(
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
GIT_CHECKOUT_SKIP_LOCKED_DIRECTORIES,
|
|
253
|
-
)
|
|
250
|
+
def _get_checkout_strategy(
|
|
251
|
+
strategy: Optional["CheckoutStrategy"] = None,
|
|
252
|
+
) -> "CheckoutStrategy":
|
|
253
|
+
from pygit2.enums import CheckoutStrategy
|
|
254
254
|
|
|
255
255
|
if strategy is None:
|
|
256
|
-
strategy =
|
|
256
|
+
strategy = CheckoutStrategy.SAFE | CheckoutStrategy.RECREATE_MISSING
|
|
257
257
|
if os.name == "nt":
|
|
258
|
-
strategy |=
|
|
258
|
+
strategy |= CheckoutStrategy.SKIP_LOCKED_DIRECTORIES
|
|
259
259
|
return strategy
|
|
260
260
|
|
|
261
261
|
# Workaround to force git_backend_odb_pack to release open file handles
|
|
@@ -342,9 +342,12 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
342
342
|
force: bool = False,
|
|
343
343
|
**kwargs,
|
|
344
344
|
):
|
|
345
|
-
from pygit2 import
|
|
345
|
+
from pygit2 import GitError
|
|
346
|
+
from pygit2.enums import CheckoutStrategy
|
|
346
347
|
|
|
347
|
-
strategy = self._get_checkout_strategy(
|
|
348
|
+
strategy = self._get_checkout_strategy(
|
|
349
|
+
CheckoutStrategy.FORCE if force else None
|
|
350
|
+
)
|
|
348
351
|
|
|
349
352
|
with self.release_odb_handles():
|
|
350
353
|
if create_new:
|
|
@@ -395,7 +398,8 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
395
398
|
annotated: bool = False,
|
|
396
399
|
message: Optional[str] = None,
|
|
397
400
|
):
|
|
398
|
-
from pygit2 import
|
|
401
|
+
from pygit2 import GitError
|
|
402
|
+
from pygit2.enums import ObjectType
|
|
399
403
|
|
|
400
404
|
if annotated and not message:
|
|
401
405
|
raise SCMError("message is required for annotated tag")
|
|
@@ -404,7 +408,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
404
408
|
self.repo.create_tag(
|
|
405
409
|
tag,
|
|
406
410
|
target_obj.id,
|
|
407
|
-
|
|
411
|
+
ObjectType.COMMIT,
|
|
408
412
|
self.committer,
|
|
409
413
|
message or "",
|
|
410
414
|
)
|
|
@@ -526,7 +530,8 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
526
530
|
self.repo.create_reference_direct(name, new_ref, True, message=message)
|
|
527
531
|
|
|
528
532
|
def get_ref(self, name, follow: bool = True) -> Optional[str]:
|
|
529
|
-
from pygit2 import
|
|
533
|
+
from pygit2 import InvalidSpecError, Tag
|
|
534
|
+
from pygit2.enums import ObjectType, ReferenceType
|
|
530
535
|
|
|
531
536
|
try:
|
|
532
537
|
ref = self.repo.references.get(name)
|
|
@@ -534,12 +539,12 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
534
539
|
return None
|
|
535
540
|
if not ref:
|
|
536
541
|
return None
|
|
537
|
-
if follow and ref.type ==
|
|
542
|
+
if follow and ref.type == ReferenceType.SYMBOLIC:
|
|
538
543
|
ref = ref.resolve()
|
|
539
544
|
try:
|
|
540
545
|
obj = self.repo[ref.target]
|
|
541
546
|
if isinstance(obj, Tag):
|
|
542
|
-
return str(obj.peel(
|
|
547
|
+
return str(obj.peel(ObjectType.COMMIT).id)
|
|
543
548
|
except ValueError:
|
|
544
549
|
pass
|
|
545
550
|
|
|
@@ -610,7 +615,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
610
615
|
force: bool = False,
|
|
611
616
|
on_diverged: Optional[Callable[[str, str], bool]] = None,
|
|
612
617
|
) -> SyncStatus:
|
|
613
|
-
import
|
|
618
|
+
from pygit2.enums import MergeAnalysis
|
|
614
619
|
|
|
615
620
|
rh_rev = self.resolve_rev(rh)
|
|
616
621
|
|
|
@@ -624,16 +629,16 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
624
629
|
self.set_ref(lh, rh_rev)
|
|
625
630
|
return SyncStatus.SUCCESS
|
|
626
631
|
|
|
627
|
-
if merge_result &
|
|
632
|
+
if merge_result & MergeAnalysis.UP_TO_DATE:
|
|
628
633
|
return SyncStatus.UP_TO_DATE
|
|
629
|
-
if merge_result &
|
|
634
|
+
if merge_result & MergeAnalysis.FASTFORWARD:
|
|
630
635
|
self.set_ref(lh, rh_rev)
|
|
631
636
|
return SyncStatus.SUCCESS
|
|
632
|
-
if merge_result &
|
|
637
|
+
if merge_result & MergeAnalysis.NORMAL:
|
|
633
638
|
if on_diverged and on_diverged(lh, rh_rev):
|
|
634
639
|
return SyncStatus.SUCCESS
|
|
635
640
|
return SyncStatus.DIVERGED
|
|
636
|
-
logger.debug("Unexpected merge result: %s",
|
|
641
|
+
logger.debug("Unexpected merge result: %s", MergeAnalysis.NORMAL)
|
|
637
642
|
raise SCMError("Unknown merge analysis result")
|
|
638
643
|
|
|
639
644
|
@contextmanager
|
|
@@ -776,7 +781,8 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
776
781
|
skip_conflicts: bool = False,
|
|
777
782
|
**kwargs,
|
|
778
783
|
):
|
|
779
|
-
from pygit2 import
|
|
784
|
+
from pygit2 import GitError
|
|
785
|
+
from pygit2.enums import CheckoutStrategy
|
|
780
786
|
|
|
781
787
|
from scmrepo.git import Stash
|
|
782
788
|
|
|
@@ -785,7 +791,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
785
791
|
self.repo.index.read(False)
|
|
786
792
|
strategy = self._get_checkout_strategy()
|
|
787
793
|
if skip_conflicts:
|
|
788
|
-
strategy |=
|
|
794
|
+
strategy |= CheckoutStrategy.ALLOW_CONFLICTS
|
|
789
795
|
self.repo.stash_apply(
|
|
790
796
|
index, strategy=strategy, reinstate_index=reinstate_index
|
|
791
797
|
)
|
|
@@ -831,7 +837,8 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
831
837
|
raise NotImplementedError
|
|
832
838
|
|
|
833
839
|
def reset(self, hard: bool = False, paths: Optional[Iterable[str]] = None):
|
|
834
|
-
from pygit2 import
|
|
840
|
+
from pygit2 import IndexEntry
|
|
841
|
+
from pygit2.enums import ResetMode
|
|
835
842
|
|
|
836
843
|
self.repo.index.read(False)
|
|
837
844
|
if paths is not None:
|
|
@@ -841,12 +848,12 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
841
848
|
if os.name == "nt":
|
|
842
849
|
rel = rel.replace("\\", "/")
|
|
843
850
|
obj = tree[rel]
|
|
844
|
-
self.repo.index.add(IndexEntry(rel, obj.
|
|
851
|
+
self.repo.index.add(IndexEntry(rel, obj.id, obj.filemode))
|
|
845
852
|
self.repo.index.write()
|
|
846
853
|
elif hard:
|
|
847
|
-
self.repo.reset(self.repo.head.target,
|
|
854
|
+
self.repo.reset(self.repo.head.target, ResetMode.HARD)
|
|
848
855
|
else:
|
|
849
|
-
self.repo.reset(self.repo.head.target,
|
|
856
|
+
self.repo.reset(self.repo.head.target, ResetMode.MIXED)
|
|
850
857
|
|
|
851
858
|
def checkout_index(
|
|
852
859
|
self,
|
|
@@ -855,22 +862,17 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
855
862
|
ours: bool = False,
|
|
856
863
|
theirs: bool = False,
|
|
857
864
|
):
|
|
858
|
-
from pygit2 import
|
|
859
|
-
GIT_CHECKOUT_ALLOW_CONFLICTS,
|
|
860
|
-
GIT_CHECKOUT_FORCE,
|
|
861
|
-
GIT_CHECKOUT_RECREATE_MISSING,
|
|
862
|
-
GIT_CHECKOUT_SAFE,
|
|
863
|
-
)
|
|
865
|
+
from pygit2.enums import CheckoutStrategy
|
|
864
866
|
|
|
865
867
|
assert not (ours and theirs)
|
|
866
|
-
strategy =
|
|
868
|
+
strategy = CheckoutStrategy.RECREATE_MISSING
|
|
867
869
|
if force or ours or theirs:
|
|
868
|
-
strategy |=
|
|
870
|
+
strategy |= CheckoutStrategy.FORCE
|
|
869
871
|
else:
|
|
870
|
-
strategy |=
|
|
872
|
+
strategy |= CheckoutStrategy.SAFE
|
|
871
873
|
|
|
872
874
|
if ours or theirs:
|
|
873
|
-
strategy |=
|
|
875
|
+
strategy |= CheckoutStrategy.ALLOW_CONFLICTS
|
|
874
876
|
strategy = self._get_checkout_strategy(strategy)
|
|
875
877
|
|
|
876
878
|
index = self.repo.index
|
|
@@ -907,18 +909,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
907
909
|
def status(
|
|
908
910
|
self, ignored: bool = False, untracked_files: str = "all"
|
|
909
911
|
) -> tuple[Mapping[str, Iterable[str]], Iterable[str], Iterable[str]]:
|
|
910
|
-
from pygit2 import
|
|
911
|
-
GIT_STATUS_IGNORED,
|
|
912
|
-
GIT_STATUS_INDEX_DELETED,
|
|
913
|
-
GIT_STATUS_INDEX_MODIFIED,
|
|
914
|
-
GIT_STATUS_INDEX_NEW,
|
|
915
|
-
GIT_STATUS_WT_DELETED,
|
|
916
|
-
GIT_STATUS_WT_MODIFIED,
|
|
917
|
-
GIT_STATUS_WT_NEW,
|
|
918
|
-
GIT_STATUS_WT_RENAMED,
|
|
919
|
-
GIT_STATUS_WT_TYPECHANGE,
|
|
920
|
-
GIT_STATUS_WT_UNREADABLE,
|
|
921
|
-
)
|
|
912
|
+
from pygit2.enums import FileStatus
|
|
922
913
|
|
|
923
914
|
staged: Mapping[str, list[str]] = {
|
|
924
915
|
"add": [],
|
|
@@ -929,19 +920,19 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
929
920
|
untracked: list[str] = []
|
|
930
921
|
|
|
931
922
|
states = {
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
923
|
+
FileStatus.WT_NEW: untracked,
|
|
924
|
+
FileStatus.WT_MODIFIED: unstaged,
|
|
925
|
+
FileStatus.WT_TYPECHANGE: staged["modify"],
|
|
926
|
+
FileStatus.WT_DELETED: staged["modify"],
|
|
927
|
+
FileStatus.WT_RENAMED: staged["modify"],
|
|
928
|
+
FileStatus.INDEX_NEW: staged["add"],
|
|
929
|
+
FileStatus.INDEX_MODIFIED: staged["modify"],
|
|
930
|
+
FileStatus.INDEX_DELETED: staged["delete"],
|
|
931
|
+
FileStatus.WT_UNREADABLE: untracked,
|
|
941
932
|
}
|
|
942
933
|
|
|
943
934
|
if untracked_files != "no" and ignored:
|
|
944
|
-
states[
|
|
935
|
+
states[FileStatus.IGNORED] = untracked
|
|
945
936
|
|
|
946
937
|
for file, state in self.repo.status(
|
|
947
938
|
untracked_files=untracked_files, ignored=ignored
|
|
@@ -960,22 +951,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
960
951
|
def iter_remote_refs(self, url: str, base: Optional[str] = None, **kwargs):
|
|
961
952
|
raise NotImplementedError
|
|
962
953
|
|
|
963
|
-
def merge( # noqa: C901
|
|
954
|
+
def merge( # noqa: C901, PLR0912
|
|
964
955
|
self,
|
|
965
956
|
rev: str,
|
|
966
957
|
commit: bool = True,
|
|
967
958
|
msg: Optional[str] = None,
|
|
968
959
|
squash: bool = False,
|
|
969
960
|
) -> Optional[str]:
|
|
970
|
-
from pygit2 import
|
|
971
|
-
|
|
972
|
-
GIT_MERGE_ANALYSIS_NONE,
|
|
973
|
-
GIT_MERGE_ANALYSIS_UNBORN,
|
|
974
|
-
GIT_MERGE_ANALYSIS_UP_TO_DATE,
|
|
975
|
-
GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY,
|
|
976
|
-
GIT_MERGE_PREFERENCE_NO_FASTFORWARD,
|
|
977
|
-
GitError,
|
|
978
|
-
)
|
|
961
|
+
from pygit2 import GitError
|
|
962
|
+
from pygit2.enums import MergeAnalysis, MergePreference
|
|
979
963
|
|
|
980
964
|
if commit and squash:
|
|
981
965
|
raise SCMError("Cannot merge with 'squash' and 'commit'")
|
|
@@ -988,9 +972,9 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
988
972
|
except GitError as exc:
|
|
989
973
|
raise SCMError("Merge analysis failed") from exc
|
|
990
974
|
|
|
991
|
-
if analysis ==
|
|
975
|
+
if analysis == MergeAnalysis.NONE:
|
|
992
976
|
raise SCMError(f"'{rev}' cannot be merged into HEAD")
|
|
993
|
-
if analysis &
|
|
977
|
+
if analysis & MergeAnalysis.UP_TO_DATE:
|
|
994
978
|
return None
|
|
995
979
|
|
|
996
980
|
try:
|
|
@@ -1003,15 +987,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
1003
987
|
raise MergeConflictError("Merge contained conflicts")
|
|
1004
988
|
|
|
1005
989
|
try:
|
|
1006
|
-
if not (squash or ff_pref &
|
|
1007
|
-
if analysis &
|
|
990
|
+
if not (squash or ff_pref & MergePreference.NO_FASTFORWARD):
|
|
991
|
+
if analysis & MergeAnalysis.FASTFORWARD:
|
|
1008
992
|
return self._merge_ff(rev, obj)
|
|
1009
993
|
|
|
1010
|
-
if analysis &
|
|
994
|
+
if analysis & MergeAnalysis.UNBORN:
|
|
1011
995
|
self.repo.set_head(obj.id)
|
|
1012
996
|
return str(obj.id)
|
|
1013
997
|
|
|
1014
|
-
if ff_pref &
|
|
998
|
+
if ff_pref & MergePreference.FASTFORWARD_ONLY:
|
|
1015
999
|
raise SCMError(f"Cannot fast-forward HEAD to '{rev}'")
|
|
1016
1000
|
|
|
1017
1001
|
if commit:
|
|
@@ -1077,7 +1061,7 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
1077
1061
|
if isinstance(tag, Tag):
|
|
1078
1062
|
return GitTag(
|
|
1079
1063
|
tag.name,
|
|
1080
|
-
str(tag.
|
|
1064
|
+
str(tag.id),
|
|
1081
1065
|
str(tag.target),
|
|
1082
1066
|
tag.tagger.name,
|
|
1083
1067
|
tag.tagger.email,
|
|
@@ -1102,19 +1086,15 @@ class Pygit2Backend(BaseGitBackend): # pylint:disable=abstract-method
|
|
|
1102
1086
|
attr: str,
|
|
1103
1087
|
source: Optional[str] = None,
|
|
1104
1088
|
) -> Optional[Union[bool, str]]:
|
|
1105
|
-
from pygit2 import
|
|
1106
|
-
|
|
1107
|
-
GIT_ATTR_CHECK_INCLUDE_COMMIT,
|
|
1108
|
-
GIT_ATTR_CHECK_INDEX_ONLY,
|
|
1109
|
-
GitError,
|
|
1110
|
-
)
|
|
1089
|
+
from pygit2 import GitError
|
|
1090
|
+
from pygit2.enums import AttrCheck
|
|
1111
1091
|
|
|
1112
1092
|
commit: Optional["Commit"] = None
|
|
1113
|
-
flags =
|
|
1093
|
+
flags = AttrCheck.FILE_THEN_INDEX
|
|
1114
1094
|
if source:
|
|
1115
1095
|
try:
|
|
1116
1096
|
commit, _ref = self._resolve_refish(source)
|
|
1117
|
-
flags =
|
|
1097
|
+
flags = AttrCheck.INDEX_ONLY | AttrCheck.INCLUDE_COMMIT
|
|
1118
1098
|
except (KeyError, GitError) as exc:
|
|
1119
1099
|
raise SCMError(f"Invalid commit '{source}'") from exc
|
|
1120
1100
|
try:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|