Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork943
Fix missing stderr when the progress parameter of _clone is None#1224
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Byron merged 3 commits intogitpython-developers:mainfromliangjingyang:fix-missing-stderrApr 22, 2021
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
Show all changes
3 commits Select commitHold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
8 changes: 3 additions & 5 deletionsgit/repo/base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -988,8 +988,6 @@ def init(cls, path: PathLike = None, mkdir: bool = True, odbt: Type[GitCmdObject | ||
def _clone(cls, git: 'Git', url: PathLike, path: PathLike, odb_default_type: Type[GitCmdObjectDB], | ||
progress: Optional[Callable], multi_options: Optional[List[str]] = None, **kwargs: Any | ||
) -> 'Repo': | ||
odbt = kwargs.pop('odbt', odb_default_type) | ||
# when pathlib.Path or other classbased path is passed | ||
@@ -1012,9 +1010,9 @@ def _clone(cls, git: 'Git', url: PathLike, path: PathLike, odb_default_type: Typ | ||
if multi_options: | ||
multi = ' '.join(multi_options).split(' ') | ||
proc = git.clone(multi, Git.polish_url(url), clone_path, with_extended_output=True, as_process=True, | ||
v=True, universal_newlines=True, **add_progress(kwargs, git,progress)) | ||
ifprogress: | ||
liangjingyang marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
handle_process_output(proc, None,to_progress_instance(progress).new_message_handler(), | ||
finalize_process, decode_streams=False) | ||
else: | ||
(stdout, stderr) = proc.communicate() | ||
32 changes: 32 additions & 0 deletionstest/test_clone.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- coding: utf-8 -*- | ||
# This module is part of GitPython and is released under | ||
# the BSD License: http://www.opensource.org/licenses/bsd-license.php | ||
from pathlib import Path | ||
import re | ||
import git | ||
from .lib import ( | ||
TestBase, | ||
with_rw_directory, | ||
) | ||
class TestClone(TestBase): | ||
@with_rw_directory | ||
def test_checkout_in_non_empty_dir(self, rw_dir): | ||
non_empty_dir = Path(rw_dir) | ||
garbage_file = non_empty_dir / 'not-empty' | ||
garbage_file.write_text('Garbage!') | ||
# Verify that cloning into the non-empty dir fails while complaining about | ||
# the target directory not being empty/non-existent | ||
try: | ||
self.rorepo.clone(non_empty_dir) | ||
except git.GitCommandError as exc: | ||
self.assertTrue(exc.stderr, "GitCommandError's 'stderr' is unexpectedly empty") | ||
expr = re.compile(r'(?is).*\bfatal:\s+destination\s+path\b.*\bexists\b.*\bnot\b.*\bempty\s+directory\b') | ||
self.assertTrue(expr.search(exc.stderr), '"%s" does not match "%s"' % (expr.pattern, exc.stderr)) | ||
else: | ||
self.fail("GitCommandError not raised") |
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.