Skip to content

Commit 59cd978

Browse files
committed
reposync: improve push error handeling
inspired by: gitpython-developers/GitPython#621 (comment) Change-Id: I98570930ac54aea57f7e632ff6599aa51d5f45d9
1 parent aca8f7b commit 59cd978

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

spicerack/reposync.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,22 @@ def _push(self, working_repo: Optional[Repo] = None) -> None:
104104
old_ssh_auth_sock = os.getenv("SSH_AUTH_SOCK")
105105
os.environ["SSH_AUTH_SOCK"] = KEYHOLDER_SOCK
106106

107-
try:
107+
try: # pylint: disable=too-many-nested-blocks
108108
for remote in working_repo.remotes:
109109
logger.debug("Attempt push to: %s", remote)
110110
try:
111111
# TODO: later versions of git python have raise_if_error
112112
push_info_list = remote.push()
113113
for push_info in push_info_list:
114114
msg = f"bitflags {push_info.flags}: {push_info.summary.strip()}"
115-
if push_info.flags & PushInfo.ERROR == PushInfo.ERROR:
116-
raise RepoSyncPushError(f"Error pushing to {remote}: {msg}")
115+
for flag in [
116+
PushInfo.REJECTED,
117+
PushInfo.REMOTE_REJECTED,
118+
PushInfo.REMOTE_FAILURE,
119+
PushInfo.ERROR,
120+
]:
121+
if push_info.flags & flag:
122+
raise RepoSyncPushError(f"Error pushing to {remote}: {msg}")
117123
# remote.push returns an empty list on error
118124
except (StopIteration, GitError) as error:
119125
raise RepoSyncPushError(f"Error pushing to {remote}: {error}") from error

0 commit comments

Comments
 (0)