Skip to content

Commit

Permalink
fix(docs): be clear about exit code handling
Browse files Browse the repository at this point in the history
When pushing/pulling, we ignore errors unless it's exit code 128.
The reason for this is now made explicit to make clear that issues
are handled by PushInfo flags accordingly.

Related #271
  • Loading branch information
Byron committed Apr 8, 2015
1 parent 98f6995 commit 723f100
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
14 changes: 11 additions & 3 deletions git/test/lib/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,13 @@ def remote_repo_creator(self):
prev_cwd = os.getcwd()
os.chdir(rw_repo.working_dir)
try:
return func(self, rw_repo, rw_remote_repo)
try:
return func(self, rw_repo, rw_remote_repo)
except:
print("Keeping repos after failure: repo_dir = %s, remote_repo_dir = %s"
% (repo_dir, remote_repo_dir), file=sys.stderr)
repo_dir = remote_repo_dir = None
raise
finally:
# gd.proc.kill() ... no idea why that doesn't work
if gd is not None:
Expand All @@ -241,8 +247,10 @@ def remote_repo_creator(self):
os.chdir(prev_cwd)
rw_repo.git.clear_cache()
rw_remote_repo.git.clear_cache()
shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror)
if repo_dir:
shutil.rmtree(repo_dir, onerror=_rmtree_onerror)
if remote_repo_dir:
shutil.rmtree(remote_repo_dir, onerror=_rmtree_onerror)

if gd is not None:
gd.proc.wait()
Expand Down
17 changes: 17 additions & 0 deletions git/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,23 @@ def finalize_process(proc):
except GitCommandError:
# if a push has rejected items, the command has non-zero return status
# a return status of 128 indicates a connection error - reraise the previous one
# Everything else will still be parsed and made available through PushInfo flags
# Estimated error results look like this:
# ```bash
# To /var/folders/xp/m48gs2tx2vg95tmtzw7tprs40000gn/T/tmpk5jeBeremote_repo_test_base
# ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward)
# Done
# error: failed to push some refs to
# '/var/folders/xp/m48gs2tx2vg95tmtzw7tprs40000gn/T/tmpk5jeBeremote_repo_test_base'
# hint: Updates were rejected because the tip of your current branch is behind
# hint: its remote counterpart. Integrate the remote changes (e.g.
# hint: 'git pull ...') before pushing again.
# hint: See the 'Note about fast-forwards' in 'git push --help' for details.
# ```
# See https://github.com/gitpython-developers/GitPython/blob/master/git/test/test_remote.py#L305
# on how to check for these kinds of errors.
# Also see this issue for a reason for this verbosity:
# https://github.com/gitpython-developers/GitPython/issues/271
if proc.poll() == 128:
raise
pass
Expand Down

0 comments on commit 723f100

Please # to comment.