| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 723f100 commit e9f8f15
4 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -7,6 +7,10 @@ Changelog | |||
| 7 | 7 | * `IndexFile.add()` will now write the index without any extension data by default. However, you may override this behaviour with the new `write_extension_data` keyword argument. | |
| 8 | 8 | ||
| 9 | 9 | - Renamed `ignore_tree_extension_data` keyword argument in `IndexFile.write(...)` to `ignore_extension_data` | |
| 10 | + * If the git command executed during `Remote.push(...)|fetch(...)` returns with an non-zero exit code and GitPython didn't | ||
| 11 | + obtain any head-information, the corresponding `GitCommandError` will be raised. This may break previous code which expected | ||
| 12 | + these operations to never raise. However, that behavious is undesirable as it would effectively hide the fact that there | ||
| 13 | + was an error. See `this issue <https://github.com/gitpython-developers/GitPython/issues/271>`_ for more information. | ||
| 10 | 14 | ||
| 11 | 15 | 0.3.6 - Features | |
| 12 | 16 | ================ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -568,7 +568,12 @@ def _get_fetch_info_from_stderr(self, proc, progress): | |||
| 568 | 568 | # end | |
| 569 | 569 | ||
| 570 | 570 | # We are only interested in stderr here ... | |
| 571 | - finalize_process(proc) | ||
| 571 | + try: | ||
| 572 | + finalize_process(proc) | ||
| 573 | + except Exception: | ||
| 574 | + if len(fetch_info_lines) == 0: | ||
| 575 | + raise | ||
| 576 | + # end exception handler | ||
| 572 | 577 | ||
| 573 | 578 | # read head information | |
| 574 | 579 | fp = open(join(self.repo.git_dir, 'FETCH_HEAD'), 'rb') | |
@@ -601,7 +606,11 @@ def stdout_handler(line): | |||
| 601 | 606 | # END exception handling | |
| 602 | 607 | # END for each line | |
| 603 | 608 | ||
| 604 | - handle_process_output(proc, stdout_handler, progress_handler, finalize_process) | ||
| 609 | + try: | ||
| 610 | + handle_process_output(proc, stdout_handler, progress_handler, finalize_process) | ||
| 611 | + except Exception: | ||
| 612 | + if len(output) == 0: | ||
| 613 | + raise | ||
| 605 | 614 | return output | |
| 606 | 615 | ||
| 607 | 616 | def fetch(self, refspec=None, progress=None, **kwargs): | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -313,8 +313,7 @@ def _assert_push_and_pull(self, remote, rw_repo, remote_repo): | |||
| 313 | 313 | self._do_test_push_result(res, remote) | |
| 314 | 314 | ||
| 315 | 315 | # invalid refspec | |
| 316 | - res = remote.push("hellothere") | ||
| 317 | - assert len(res) == 0 | ||
| 316 | + self.failUnlessRaises(GitCommandError, remote.push, "hellothere") | ||
| 318 | 317 | ||
| 319 | 318 | # push new tags | |
| 320 | 319 | progress = TestRemoteProgress() | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -16,10 +16,7 @@ | |||
| 16 | 16 | ||
| 17 | 17 | # NOTE: Some of the unused imports might be used/imported by others. | |
| 18 | 18 | # Handle once test-cases are back up and running. | |
| 19 | - from .exc import ( | ||
| 20 | - GitCommandError, | ||
| 21 | - InvalidGitRepositoryError | ||
| 22 | - ) | ||
| 19 | + from .exc import InvalidGitRepositoryError | ||
| 23 | 20 | ||
| 24 | 21 | from .compat import ( | |
| 25 | 22 | MAXSIZE, | |
@@ -154,32 +151,7 @@ def get_user_id(): | |||
| 154 | 151 | ||
| 155 | 152 | def finalize_process(proc): | |
| 156 | 153 | """Wait for the process (clone, fetch, pull or push) and handle its errors accordingly""" | |
| 157 | - try: | ||
| 158 | - proc.wait() | ||
| 159 | - except GitCommandError: | ||
| 160 | - # if a push has rejected items, the command has non-zero return status | ||
| 161 | - # a return status of 128 indicates a connection error - reraise the previous one | ||
| 162 | - # Everything else will still be parsed and made available through PushInfo flags | ||
| 163 | - # Estimated error results look like this: | ||
| 164 | - # ```bash | ||
| 165 | - # To /var/folders/xp/m48gs2tx2vg95tmtzw7tprs40000gn/T/tmpk5jeBeremote_repo_test_base | ||
| 166 | - # ! refs/heads/master:refs/heads/master [rejected] (non-fast-forward) | ||
| 167 | - # Done | ||
| 168 | - # error: failed to push some refs to | ||
| 169 | - # '/var/folders/xp/m48gs2tx2vg95tmtzw7tprs40000gn/T/tmpk5jeBeremote_repo_test_base' | ||
| 170 | - # hint: Updates were rejected because the tip of your current branch is behind | ||
| 171 | - # hint: its remote counterpart. Integrate the remote changes (e.g. | ||
| 172 | - # hint: 'git pull ...') before pushing again. | ||
| 173 | - # hint: See the 'Note about fast-forwards' in 'git push --help' for details. | ||
| 174 | - # ``` | ||
| 175 | - # See https://github.com/gitpython-developers/GitPython/blob/master/git/test/test_remote.py#L305 | ||
| 176 | - # on how to check for these kinds of errors. | ||
| 177 | - # Also see this issue for a reason for this verbosity: | ||
| 178 | - # https://github.com/gitpython-developers/GitPython/issues/271 | ||
| 179 | - if proc.poll() == 128: | ||
| 180 | - raise | ||
| 181 | - pass | ||
| 182 | - # END exception handling | ||
| 154 | + proc.wait() | ||
| 183 | 155 | ||
| 184 | 156 | #} END utilities | |
| 185 | 157 | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments