comparison env/lib/python3.9/site-packages/planemo/commands/cmd_clone.py @ 0:4f3585e2f14b draft default tip

"planemo upload commit 60cee0fc7c0cda8592644e1aad72851dec82c959"
author shellac
date Mon, 22 Mar 2021 18:12:50 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4f3585e2f14b
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 access token is
62 specified in ~/.planemo.yml. An access token can be generated by going
63 to https://github.com/settings/tokens.
64 """
65 if target in CLONE_GITHUB_TARGETS:
66 target = "https://github.com/%s" % CLONE_GITHUB_TARGETS[target]
67 # Pretty hacky that this path isn't treated as None.
68 if path is None or path.endswith("__NONE__"):
69 path = target.split("/")[-1]
70 github_util.clone_fork_branch(ctx, target, path, **kwds)