| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 31cc047 commit 41b9cea
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -30,5 +30,6 @@ Contributors are: | |||
| 30 | 30 | -William Luc Ritchie | |
| 31 | 31 | -David Host <hostdm _at_ outlook.com> | |
| 32 | 32 | -A. Jesse Jiryu Davis <jesse _at_ emptysquare.net> | |
| 33 | + -Steven Whitman <ninloot _at_ gmail.com> | ||
| 33 | 34 | ||
| 34 | 35 | Portions derived from other open source works and are clearly marked. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -931,7 +931,7 @@ def init(cls, path=None, mkdir=True, odbt=GitCmdObjectDB, expand_vars=True, **kw | |||
| 931 | 931 | return cls(path, odbt=odbt) | |
| 932 | 932 | ||
| 933 | 933 | @classmethod | |
| 934 | - def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): | ||
| 934 | + def _clone(cls, git, url, path, odb_default_type, progress, multi_options=None, **kwargs): | ||
| 935 | 935 | if progress is not None: | |
| 936 | 936 | progress = to_progress_instance(progress) | |
| 937 | 937 | ||
@@ -953,7 +953,10 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): | |||
| 953 | 953 | sep_dir = kwargs.get('separate_git_dir') | |
| 954 | 954 | if sep_dir: | |
| 955 | 955 | kwargs['separate_git_dir'] = Git.polish_url(sep_dir) | |
| 956 | - proc = git.clone(Git.polish_url(url), clone_path, with_extended_output=True, as_process=True, | ||
| 956 | + multi = None | ||
| 957 | + if multi_options: | ||
| 958 | + multi = ' '.join(multi_options).split(' ') | ||
| 959 | + proc = git.clone(multi, Git.polish_url(url), clone_path, with_extended_output=True, as_process=True, | ||
| 957 | 960 | v=True, universal_newlines=True, **add_progress(kwargs, git, progress)) | |
| 958 | 961 | if progress: | |
| 959 | 962 | handle_process_output(proc, None, progress.new_message_handler(), finalize_process, decode_streams=False) | |
@@ -983,33 +986,38 @@ def _clone(cls, git, url, path, odb_default_type, progress, **kwargs): | |||
| 983 | 986 | # END handle remote repo | |
| 984 | 987 | return repo | |
| 985 | 988 | ||
| 986 | - def clone(self, path, progress=None, **kwargs): | ||
| 989 | + def clone(self, path, progress=None, multi_options=None, **kwargs): | ||
| 987 | 990 | """Create a clone from this repository. | |
| 988 | 991 | ||
| 989 | 992 | :param path: is the full path of the new repo (traditionally ends with ./<name>.git). | |
| 990 | 993 | :param progress: See 'git.remote.Remote.push'. | |
| 994 | + :param multi_options: A list of Clone options that can be provided multiple times. One | ||
| 995 | + option per list item which is passed exactly as specified to clone. | ||
| 996 | + For example ['--config core.filemode=false', '--config core.ignorecase', | ||
| 997 | + '--recurse-submodule=repo1_path', '--recurse-submodule=repo2_path'] | ||
| 991 | 998 | :param kwargs: | |
| 992 | 999 | * odbt = ObjectDatabase Type, allowing to determine the object database | |
| 993 | 1000 | implementation used by the returned Repo instance | |
| 994 | 1001 | * All remaining keyword arguments are given to the git-clone command | |
| 995 | 1002 | ||
| 996 | 1003 | :return: ``git.Repo`` (the newly cloned repo)""" | |
| 997 | - return self._clone(self.git, self.common_dir, path, type(self.odb), progress, **kwargs) | ||
| 1004 | + return self._clone(self.git, self.common_dir, path, type(self.odb), progress, multi_options, **kwargs) | ||
| 998 | 1005 | ||
| 999 | 1006 | @classmethod | |
| 1000 | - def clone_from(cls, url, to_path, progress=None, env=None, **kwargs): | ||
| 1007 | + def clone_from(cls, url, to_path, progress=None, env=None, multi_options=None, **kwargs): | ||
| 1001 | 1008 | """Create a clone from the given URL | |
| 1002 | 1009 | ||
| 1003 | 1010 | :param url: valid git url, see http://www.kernel.org/pub/software/scm/git/docs/git-clone.html#URLS | |
| 1004 | 1011 | :param to_path: Path to which the repository should be cloned to | |
| 1005 | 1012 | :param progress: See 'git.remote.Remote.push'. | |
| 1006 | 1013 | :param env: Optional dictionary containing the desired environment variables. | |
| 1014 | + :param mutli_options: See ``clone`` method | ||
| 1007 | 1015 | :param kwargs: see the ``clone`` method | |
| 1008 | 1016 | :return: Repo instance pointing to the cloned directory""" | |
| 1009 | 1017 | git = Git(os.getcwd()) | |
| 1010 | 1018 | if env is not None: | |
| 1011 | 1019 | git.update_environment(**env) | |
| 1012 | - return cls._clone(git, url, to_path, GitCmdObjectDB, progress, **kwargs) | ||
| 1020 | + return cls._clone(git, url, to_path, GitCmdObjectDB, progress, multi_options, **kwargs) | ||
| 1013 | 1021 | ||
| 1014 | 1022 | def archive(self, ostream, treeish=None, prefix=None, **kwargs): | |
| 1015 | 1023 | """Archive the tree at the given revision. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -229,6 +229,22 @@ def test_clone_from_pathlib(self, rw_dir): | |||
| 229 | 229 | ||
| 230 | 230 | Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib") | |
| 231 | 231 | ||
| 232 | + @with_rw_directory | ||
| 233 | + def test_clone_from_pathlib_withConfig(self, rw_dir): | ||
| 234 | + if pathlib is None: # pythons bellow 3.4 don't have pathlib | ||
| 235 | + raise SkipTest("pathlib was introduced in 3.4") | ||
| 236 | + | ||
| 237 | + original_repo = Repo.init(osp.join(rw_dir, "repo")) | ||
| 238 | + | ||
| 239 | + cloned = Repo.clone_from(original_repo.git_dir, pathlib.Path(rw_dir) / "clone_pathlib_withConfig", | ||
| 240 | + multi_options=["--recurse-submodules=repo", | ||
| 241 | + "--config core.filemode=false", | ||
| 242 | + "--config submodule.repo.update=checkout"]) | ||
| 243 | + | ||
| 244 | + assert_equal(cloned.config_reader().get_value('submodule', 'active'), 'repo') | ||
| 245 | + assert_equal(cloned.config_reader().get_value('core', 'filemode'), False) | ||
| 246 | + assert_equal(cloned.config_reader().get_value('submodule "repo"', 'update'), 'checkout') | ||
| 247 | + | ||
| 232 | 248 | @with_rw_repo('HEAD') | |
| 233 | 249 | def test_max_chunk_size(self, repo): | |
| 234 | 250 | class TestOutputStream(object): | |
| Back | FazBrowse Home | New Git URL |
0 commit comments