diff --git a/metomi/rose/loc_handlers/git.py b/metomi/rose/loc_handlers/git.py index a06841ea0..c37c80777 100644 --- a/metomi/rose/loc_handlers/git.py +++ b/metomi/rose/loc_handlers/git.py @@ -87,17 +87,9 @@ def parse(self, loc, conf_tree): self.manager.popen.run_ok( "git", git_dir_opt, "init" ) - self.manager.popen.run_ok( - "git", git_dir_opt, "remote", "add", "origin", remote - ) # Make sure we configure for minimum fetching. - if self.git_version >= (2, 25, 0): - self.manager.popen.run_ok( - "git", git_dir_opt, "sparse-checkout", "set", path, - "--no-cone" - ) - else: + if self.git_version < (2, 25, 0): self.manager.popen.run_ok( "git", git_dir_opt, "config", "extensions.partialClone", "true" @@ -109,7 +101,7 @@ def parse(self, loc, conf_tree): # Fetch the ref/commit as efficiently as we can. ret_code, _, stderr = self.manager.popen.run( "git", git_dir_opt, "fetch", "--depth=1", - "--filter=blob:none", "origin", commithash + "--filter=blob:none", remote, commithash ) if ret_code: raise ValueError(f"source={loc.name}: {stderr}") @@ -145,9 +137,6 @@ async def pull(self, loc, conf_tree): await self.manager.popen.run_ok_async( "git", git_dir_opt, "init" ) - await self.manager.popen.run_ok_async( - "git", git_dir_opt, "remote", "add", "origin", remote - ) if self.git_version >= (2, 25, 0) and path != "./": await self.manager.popen.run_ok_async( "git", git_dir_opt, "sparse-checkout", "set", path, @@ -155,11 +144,11 @@ async def pull(self, loc, conf_tree): ) await self.manager.popen.run_ok_async( "git", git_dir_opt, "fetch", "--depth=1", - "--filter=blob:none", "origin", loc.key + "--filter=blob:none", remote, loc.key ) else: await self.manager.popen.run_ok_async( - "git", git_dir_opt, "fetch", "--depth=1", "origin", loc.key + "git", git_dir_opt, "fetch", "--depth=1", remote, loc.key ) await self.manager.popen.run_ok_async( diff --git a/sphinx/api/configuration/file-creation.rst b/sphinx/api/configuration/file-creation.rst index fe565aaaf..47c19c344 100644 --- a/sphinx/api/configuration/file-creation.rst +++ b/sphinx/api/configuration/file-creation.rst @@ -37,7 +37,29 @@ root directory to install file targets with a relative path: cloned ``REPOSITORY_URL``, git checkout'ed ``TREEISH``, and extracted the path ``PATHSPEC`` within the clone. To extract from the root of the repository use a ``PATHSPEC`` of ``./`` e.g. - ``git:git@github.com:metomi/rose::./::2.2.0``. + ``git:git@github.com:metomi/rose::./::2.2.0``. It may help to think + of the parts of the location as git:Where::What::When. Examples: + + .. code-block:: rose + + # Download the sphinx directory from the master branch of + # the github.com/metomi/rose repo. + [file:rose-docs] + source=git:git@github.com:metomi/rose::sphinx::master + + # Extract the whole contents of version 2.0.1 of the local + # repository at /home/user/some/path/to/my/git/repo. + [file:all_of_my_repo] + source=git:/home/user/some/path/to/my/git/repo::./::2.0.1 + + # Extract a single file from a particular commit of a repo + # on a machine that we have ssh access to. + [file:my_file] + source=git:machine01:/data/user/my_repo_name::etc/my_file::7261bff4d9a6c582ec759ef52c46dd794fe8794e + + You should set ``git config uploadpack.allowFilter true`` and + ``git config uploadpack.allowAnySHA1InWant true`` on repositories + if you are setting them up to pull from. :opt rsync: This scheme is useful for pulling a file or directory from a remote host using ``rsync`` via ``ssh``. A URI should have the form ``HOST:PATH``.