comparison env/lib/python3.7/site-packages/planemo/commands/cmd_clone.py @ 5:9b1c78e6ba9c draft default tip

"planemo upload commit 6c0a8142489327ece472c84e558c47da711a9142"
author shellac
date Mon, 01 Jun 2020 08:59:25 -0400
parents 79f47841a781
children
comparison
equal deleted inserted replaced
4:79f47841a781 5:9b1c78e6ba9c
1 """Module describing the planemo ``recipe_init`` command."""
2 import click
3
4 from planemo import github_util
5 from planemo import options
6 from planemo.cli import command_function
7 from planemo.config import planemo_option
8
9
10 CLONE_GITHUB_TARGETS = {
11 "tools-iuc": "galaxyproject/tools-iuc",
12 "tools-devteam": "galaxyproject/tools-devteam",
13 "galaxy": "galaxyproject/galaxy",
14 "planemo": "galaxyproject/planemo",
15 "tools-galaxyp": "galaxyproteomics/tools-galaxyp",
16 "bioconda-recipes": "bioconda/bioconda-recipes",
17 "homebrew-science": "Homebrew/homebrew-science",
18 "workflows": "common-workflow-language/workflows",
19 }
20
21
22 def clone_target_arg():
23 """Represent target to clone/branch."""
24 return click.argument(
25 "target",
26 metavar="TARGET",
27 type=click.STRING,
28 )
29
30
31 @click.command('clone')
32 @planemo_option(
33 "--fork/--skip_fork",
34 default=True,
35 is_flag=True,
36 )
37 @planemo_option(
38 "--branch",
39 type=click.STRING,
40 default=None,
41 help="Create a named branch on result."
42 )
43 @clone_target_arg()
44 @options.optional_project_arg(exists=None, default="__NONE__")
45 @command_function
46 def cli(ctx, target, path, **kwds):
47 """Short-cut to quickly clone, fork, and branch a relevant Github repo.
48
49 For instance, the following will clone, fork, and branch the tools-iuc
50 repository to allow a subsequent pull request to fix a problem with bwa.
51
52
53 \b
54 $ planemo clone --branch bwa-fix tools-iuc
55 $ cd tools-iuc
56 $ # Make changes.
57 $ git add -p # Add desired changes.
58 $ git commit -m "Fix bwa problem."
59 $ planemo pull_request -m "Fix bwa problem."
60
61 These changes do require that a github username and password are
62 specified in ~/.planemo.yml.
63 """
64 if target in CLONE_GITHUB_TARGETS:
65 target = "https://github.com/%s" % CLONE_GITHUB_TARGETS[target]
66 # Pretty hacky that this path isn't treated as None.
67 if path is None or path.endswith("__NONE__"):
68 path = target.split("/")[-1]
69 github_util.clone_fork_branch(ctx, target, path, **kwds)