◐ Shell
reader mode source ↗
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
File filter
Conversations
Jump to
Diff view
Apply and reload
Show whitespace
Diff view
Apply and reload
2 changes: 1 addition & 1 deletion .github/workflows/pythonpackage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [3.7, 3.7.5, 3.7.12, 3.8, 3.8.0, 3.8.11, 3.8, 3.9, 3.9.0, 3.9.7, "3.10"]

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 4 additions & 0 deletions git/exc.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ class NoSuchPathError(GitError, OSError):
"""Thrown if a path could not be access by the system."""


class CommandError(GitError):
"""Base class for exceptions thrown at every stage of `Popen()` execution.

31 changes: 30 additions & 1 deletion git/repo/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@
)
from git.config import GitConfigParser
from git.db import GitCmdObjectDB
from git.exc import InvalidGitRepositoryError, NoSuchPathError, GitCommandError
from git.index import IndexFile
from git.objects import Submodule, RootModule, Commit
from git.refs import HEAD, Head, Reference, TagReference
Expand Down @@ -128,6 +133,7 @@ class Repo(object):
re_envvars = re.compile(r"(\$(\{\s?)?[a-zA-Z_]\w*(\}\s?)?|%\s?[a-zA-Z_]\w*\s?%)")
re_author_committer_start = re.compile(r"^(author|committer)")
re_tab_full_line = re.compile(r"^\t(.*)$")

# invariants
# represents the configuration level of a configuration file
Expand Down Expand Up @@ -1214,11 +1220,27 @@ def _clone(
# END handle remote repo
return repo

def clone(
self,
path: PathLike,
progress: Optional[Callable] = None,
multi_options: Optional[List[str]] = None,
**kwargs: Any,
) -> "Repo":
"""Create a clone from this repository.
Expand All @@ -1229,12 +1251,15 @@ def clone(
option per list item which is passed exactly as specified to clone.
For example ['--config core.filemode=false', '--config core.ignorecase',
'--recurse-submodule=repo1_path', '--recurse-submodule=repo2_path']
:param kwargs:
* odbt = ObjectDatabase Type, allowing to determine the object database
implementation used by the returned Repo instance
* All remaining keyword arguments are given to the git-clone command

:return: ``git.Repo`` (the newly cloned repo)"""
return self._clone(
self.git,
self.common_dir,
Expand All @@ -1253,6 +1278,7 @@ def clone_from(
progress: Optional[Callable] = None,
env: Optional[Mapping[str, str]] = None,
multi_options: Optional[List[str]] = None,
**kwargs: Any,
) -> "Repo":
"""Create a clone from the given URL
Expand All @@ -1267,11 +1293,14 @@ def clone_from(
If you want to unset some variable, consider providing empty string
as its value.
:param multi_options: See ``clone`` method
:param kwargs: see the ``clone`` method
:return: Repo instance pointing to the cloned directory"""
git = cls.GitCommandWrapperType(os.getcwd())
if env is not None:
git.update_environment(**env)
return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs)

def archive(
Expand Down
36 changes: 36 additions & 0 deletions test/test_repo.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import pickle
import sys
import tempfile
from unittest import mock, skipIf, SkipTest

import pytest
Expand All @@ -37,6 +38,7 @@
)
from git.exc import (
BadObject,
)
from git.repo.fun import touch
from test.lib import TestBase, with_rw_repo, fixture
Expand Down Expand Up @@ -263,6 +265,40 @@ def test_leaking_password_in_clone_logs(self, rw_dir):
to_path=rw_dir,
)

@with_rw_repo("HEAD")
def test_max_chunk_size(self, repo):
class TestOutputStream(TestBase):
Expand Down
Toggle all file notes Toggle all file annotations