Skip to content

Commit 3dc4975

Browse files
committed
dulwich: check for rejected pack in push_refspecs
1 parent c65c094 commit 3dc4975

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

+13-2
Original file line numberDiff line numberDiff line change
@@ -508,7 +508,7 @@ def iter_remote_refs(self, url: str, base: Optional[str] = None, **kwargs):
508508
def get_refs_containing(self, rev: str, pattern: Optional[str] = None):
509509
raise NotImplementedError
510510

511-
def push_refspecs(
511+
def push_refspecs( # noqa: C901
512512
self,
513513
url: str,
514514
refspecs: Union[str, Iterable[str]],
@@ -568,7 +568,7 @@ def update_refs(refs):
568568
return new_refs
569569

570570
try:
571-
client.send_pack(
571+
result = client.send_pack(
572572
path,
573573
update_refs,
574574
self.repo.object_store.generate_pack_data,
@@ -579,6 +579,17 @@ def update_refs(refs):
579579
raise SCMError(f"Git failed to push '{src}' to '{url}'") from exc
580580
except HTTPUnauthorized as exc:
581581
raise AuthError(url) from exc
582+
if result.ref_status and any(
583+
(value is not None) for value in result.ref_status.values()
584+
):
585+
reasons = ", ".join(
586+
(
587+
f"{os.fsdecode(ref)}: {reason}"
588+
for ref, reason in result.ref_status.items()
589+
if reason is not None
590+
)
591+
)
592+
raise SCMError(f"Git failed to push some refs to '{url}' ({reasons})")
582593
return change_result
583594

584595
def fetch_refspecs(

0 commit comments

Comments
 (0)