in python/example_code/codecommit/push-in-parts.py [0:0]
def do_push_with_retries(self, ref=None, push_tags=False):
for i in range(0, self.PUSH_RETRY_LIMIT):
if i == 0:
progress_printer = PushProgressPrinter()
else:
progress_printer = None
try:
if push_tags:
infos = self.remote_repo.push(tags=True, progress=progress_printer)
elif ref is not None:
infos = self.remote_repo.push(refspec=ref, progress=progress_printer)
else:
infos = self.remote_repo.push(progress=progress_printer)
success = True
if len(infos) == 0:
success = False
else:
for info in infos:
if info.flags & info.UP_TO_DATE or info.flags & info.NEW_TAG or info.flags & info.NEW_HEAD:
continue
success = False
print(info.summary)
if success:
return
except GitCommandError as err:
print(err)
if push_tags:
print("Pushing all tags failed after %d attempts" % (self.PUSH_RETRY_LIMIT))
elif ref is not None:
print("Pushing %s failed after %d attempts" % (ref, self.PUSH_RETRY_LIMIT))
print("For more information about the cause of this error, run the following command from the local repo: 'git push %s %s'" % (self.remote_name, ref))
else:
print("Pushing all branches failed after %d attempts" % (self.PUSH_RETRY_LIMIT))
sys.exit(1)