Skip to content

Raise exception when push fails #1354

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions git/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -794,15 +794,7 @@ def stdout_handler(line: str) -> None:
handle_process_output(proc, stdout_handler, progress_handler, finalizer=None, decode_streams=False,
kill_after_timeout=kill_after_timeout)
stderr_text = progress.error_lines and '\n'.join(progress.error_lines) or ''
try:
proc.wait(stderr=stderr_text)
except Exception:
# This is different than fetch (which fails if there is any std_err
# even if there is an output)
if not output:
raise
elif stderr_text:
log.warning("Error lines received while fetching: %s", stderr_text)
proc.wait(stderr=stderr_text)

return output

Expand Down
19 changes: 6 additions & 13 deletions test/test_remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -330,10 +330,8 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):

# rejected - undo last commit
lhead.reset("HEAD~1")
res = remote.push(lhead.reference)
self.assertTrue(res[0].flags & PushInfo.ERROR)
self.assertTrue(res[0].flags & PushInfo.REJECTED)
self._do_test_push_result(res, remote)
with self.assertRaises(GitCommandError):
remote.push(lhead.reference)

# force rejected pull
res = remote.push('+%s' % lhead.reference)
Expand All @@ -357,10 +355,8 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):
# update push new tags
# Rejection is default
new_tag = TagReference.create(rw_repo, to_be_updated, reference='HEAD~1', force=True)
res = remote.push(tags=True)
self._do_test_push_result(res, remote)
self.assertTrue(res[-1].flags & PushInfo.REJECTED)
self.assertTrue(res[-1].flags & PushInfo.ERROR)
with self.assertRaises(GitCommandError):
remote.push(tags=True)

# push force this tag
res = remote.push("+%s" % new_tag.path)
Expand All @@ -386,11 +382,8 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo):

# rejected stale delete
force_with_lease = "%s:0000000000000000000000000000000000000000" % new_head.path
res = remote.push(":%s" % new_head.path, force_with_lease=force_with_lease)
self.assertTrue(res[0].flags & PushInfo.ERROR)
self.assertTrue(res[0].flags & PushInfo.REJECTED)
self.assertIsNone(res[0].local_ref)
self._do_test_push_result(res, remote)
with self.assertRaises(GitCommandError):
remote.push(":%s" % new_head.path, force_with_lease=force_with_lease)

# delete new branch on the remote end and locally
res = remote.push(":%s" % new_head.path)
Expand Down