commit dab3fc56b073c166084672ac0834eb2c35445470 from: Jelmer Vernooij via: GitHub date: Sun Oct 23 19:23:12 2022 UTC Merge pull request #1077 from jelmer/clone-b Add -b argument to "dulwich clone" commit - 1997f839a022252a607d6dff033bdd52f62fff41 commit + dab3fc56b073c166084672ac0834eb2c35445470 blob - 0bf0e1f3ab41a828ded9c8b28fe5df0c454dfb69 blob + 85c2a5bf2041f9546f86bc088dff9040204ad870 --- NEWS +++ NEWS @@ -1,5 +1,8 @@ 0.20.47 UNRELEASED + * Add -b argument to ``dulwich clone``. + (Jelmer Vernooij) + * On Windows, provide a hint about developer mode when creating symlinks fails due to a permission error. (Jelmer Vernooij, #1005) blob - 4ccf991c68199e54a231d3c462ef64b02c8a6462 blob + 184bd9c95a90510d9482bd0027e10c392371b32d --- dulwich/cli.py +++ dulwich/cli.py @@ -247,6 +247,10 @@ class cmd_clone(Command): parser.add_option( "--depth", dest="depth", type=int, help="Depth at which to fetch" ) + parser.add_option( + "-b", "--branch", dest="branch", type=str, + help=("Check out branch instead of branch pointed to by remote " + "HEAD")) options, args = parser.parse_args(args) if args == []: @@ -259,7 +263,8 @@ class cmd_clone(Command): else: target = None - porcelain.clone(source, target, bare=options.bare, depth=options.depth) + porcelain.clone(source, target, bare=options.bare, depth=options.depth, + branch=options.branch) class cmd_commit(Command): blob - 7082e3ef4a4dd03cbf99f179474c09e060f75f4e blob + a8b70fc9b178e51d95019231a9060d91f04c3180 --- dulwich/client.py +++ dulwich/client.py @@ -1397,7 +1397,8 @@ class SubprocessGitClient(TraditionalGitClient): class LocalGitClient(GitClient): """Git Client that just uses a local Repo.""" - def __init__(self, thin_packs=True, report_activity=None, config=None): + def __init__(self, thin_packs=True, report_activity=None, + config: Optional[Config] = None): """Create a new LocalGitClient instance. Args: blob - 2a397a75c225d04b76d94183dc20829ddd6d475d blob + 479c2d1e381ac7a33f2c2ef2b156665d3aa17ac4 --- dulwich/porcelain.py +++ dulwich/porcelain.py @@ -89,6 +89,7 @@ from dulwich.client import ( get_transport_and_path, ) from dulwich.config import ( + Config, ConfigFile, StackedConfig, read_submodules, @@ -496,10 +497,10 @@ def clone( checkout=None, errstream=default_bytes_err_stream, outstream=None, - origin="origin", - depth=None, - branch=None, - config=None, + origin: Optional[str] = "origin", + depth: Optional[int] = None, + branch: Optional[Union[str, bytes]] = None, + config: Optional[Config] = None, **kwargs ): """Clone a local or remote git repository. @@ -538,6 +539,9 @@ def clone( if target is None: target = source.split("/")[-1] + + if isinstance(branch, str): + branch = branch.encode(DEFAULT_ENCODING) mkdir = not os.path.exists(target) @@ -1709,7 +1713,7 @@ def fetch( return fetch_result -def ls_remote(remote, config=None, **kwargs): +def ls_remote(remote, config: Optional[Config] = None, **kwargs): """List the refs in a remote. Args: