Skip to content

Commit

Permalink
Merge pull request #374 from JrGoodle/sources
Browse files Browse the repository at this point in the history
Add separate value for git protocol
  • Loading branch information
JrGoodle committed Nov 6, 2017
2 parents de7f5f8 + 83a16cf commit 3941b1b
Show file tree
Hide file tree
Showing 47 changed files with 400 additions and 276 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ examples/cocos2d-objc/.clowder
examples/cocos2d-objc/clowder.yaml
examples/cocos2d-objc/peru.yaml
examples/cocos2d-objc/cocos2d-objc
examples/cocos2d-objc/cocos2d-x

# Created by https://www.gitignore.io/api/osx,python

Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/branch_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
filter_groups,
Expand All @@ -19,6 +15,8 @@
run_group_command,
run_project_command
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required


class BranchController(ArgparseController):
Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/checkout_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
filter_groups,
Expand All @@ -19,6 +15,8 @@
run_group_command,
run_project_command
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required


class CheckoutController(ArgparseController):
Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/clean_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
filter_groups,
Expand All @@ -19,6 +15,8 @@
run_group_command,
run_project_command
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required


class CleanController(ArgparseController):
Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/diff_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
filter_groups,
Expand All @@ -19,6 +15,8 @@
run_group_command,
run_project_command
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required


class DiffController(ArgparseController):
Expand Down
8 changes: 3 additions & 5 deletions clowder/clowder/cli/forall_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.parallel import forall
from clowder.cli.util import options_help_message
from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required


class ForallController(ArgparseController):
Expand Down
13 changes: 7 additions & 6 deletions clowder/clowder/cli/herd_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.parallel import (
herd,
herd_parallel
)
from clowder.cli.util import options_help_message
from clowder.clowder_repo import (
print_clowder_repo_status_fetch,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.clowder_repo import print_clowder_repo_status_fetch
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.connectivity import network_connection_required


Expand All @@ -35,6 +33,8 @@ class Meta:
help='Clone and update projects with latest changes',
arguments=[
(['--parallel'], dict(action='store_true', help='run commands in parallel')),
(['--protocol'], dict(choices=['https', 'ssh'], nargs=1, default=None, metavar='PROTOCOL',
help='Protocol to clone new repos with')),
(['--rebase', '-r'], dict(action='store_true', help='use rebase instead of pull')),
(['--depth', '-d'], dict(default=None, type=int, nargs=1, metavar='DEPTH', help='depth to herd')),
(['--branch', '-b'], dict(nargs=1, default=None, metavar='BRANCH', help='branch to herd if present')),
Expand Down Expand Up @@ -68,10 +68,11 @@ def _herd(self):
branch = None if self.app.pargs.branch is None else self.app.pargs.branch[0]
tag = None if self.app.pargs.tag is None else self.app.pargs.tag[0]
depth = None if self.app.pargs.depth is None else self.app.pargs.depth[0]
protocol = None if self.app.pargs.protocol is None else self.app.pargs.protocol[0]

kwargs = {'group_names': self.app.pargs.groups, 'project_names': self.app.pargs.projects,
'skip': self.app.pargs.skip, 'branch': branch, 'tag': tag,
'depth': depth, 'rebase': self.app.pargs.rebase}
'depth': depth, 'rebase': self.app.pargs.rebase, 'protocol': protocol}
if self.app.pargs.parallel:
herd_parallel(CLOWDER_CONTROLLER, **kwargs)
return
Expand Down
2 changes: 1 addition & 1 deletion clowder/clowder/cli/link_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@
)
from clowder.clowder_repo import (
CLOWDER_REPO,
clowder_required,
print_clowder_repo_status
)
from clowder.util.decorators import clowder_required


class LinkController(ArgparseController):
Expand Down
23 changes: 15 additions & 8 deletions clowder/clowder/cli/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,18 @@
from clowder.util.progress import Progress


def herd_project(project, branch, tag, depth, rebase):
def herd_project(project, branch, tag, depth, rebase, protocol):
"""Herd command wrapper function for multiprocessing Pool execution
:param Project project: Project instance
:param str branch: Branch to attempt to herd
:param str tag: Tag to attempt to herd
:param int depth: Git clone depth. 0 indicates full clone, otherwise must be a positive integer
:param bool rebase: Whether to use rebase instead of pulling latest changes
:param str protocol: Git protocol ('ssh' or 'https')
"""

project.herd(branch=branch, tag=tag, depth=depth, rebase=rebase, parallel=True)
project.herd(branch=branch, tag=tag, depth=depth, rebase=rebase, parallel=True, protocol=protocol)


def reset_project(project, timestamp):
Expand Down Expand Up @@ -154,7 +155,7 @@ def forall(clowder, command, ignore_errors, group_names, **kwargs):
def herd(clowder, group_names, **kwargs):
"""Clone projects or update latest from upstream
.. py:function:: herd(group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[])
.. py:function:: herd(group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None)
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to herd
Expand All @@ -163,6 +164,7 @@ def herd(clowder, group_names, **kwargs):
branch (str): Branch to attempt to herd
tag (str): Tag to attempt to herd
depth (int): Git clone depth. 0 indicates full clone, otherwise must be a positive integer
protocol (str): Git protocol ('ssh' or 'https')
rebase (bool): Whether to use rebase instead of pulling latest changes
project_names (list[str]) project_names: Project names to herd
skip (list[str]): Project names to skip
Expand All @@ -174,24 +176,27 @@ def herd(clowder, group_names, **kwargs):
tag = kwargs.get('tag', None)
depth = kwargs.get('depth', None)
rebase = kwargs.get('rebase', False)
protocol = kwargs.get('protocol', None)

if project_names is None:
groups = filter_groups(clowder.groups, group_names)
validate_groups(groups)
for group in groups:
run_group_command(group, skip, 'herd', branch=branch, tag=tag, depth=depth, rebase=rebase)
run_group_command(group, skip, 'herd', branch=branch, tag=tag,
depth=depth, rebase=rebase, protocol=protocol)
return

projects = filter_projects_on_project_names(clowder.groups, project_names)
validate_projects(projects)
for project in projects:
run_project_command(project, skip, 'herd', branch=branch, tag=tag, depth=depth, rebase=rebase)
run_project_command(project, skip, 'herd', branch=branch, tag=tag,
depth=depth, rebase=rebase, protocol=protocol)


def herd_parallel(clowder, group_names, **kwargs):
"""Clone projects or update latest from upstream in parallel
.. py:function:: herd_parallel(group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[])
.. py:function:: herd_parallel(group_names, branch=None, tag=None, depth=0, rebase=False, project_names=None, skip=[], protocol=None)
:param ClowderController clowder: ClowderController instance
:param list[str] group_names: Group names to herd
Expand All @@ -200,6 +205,7 @@ def herd_parallel(clowder, group_names, **kwargs):
branch (str): Branch to attempt to herd
tag (str): Tag to attempt to herd
depth (int): Git clone depth. 0 indicates full clone, otherwise must be a positive integer
protocol (str): Git protocol ('ssh' or 'https')
rebase (bool): Whether to use rebase instead of pulling latest changes
project_names (list[str]): Project names to herd
skip (list[str]): Project names to skip
Expand All @@ -211,6 +217,7 @@ def herd_parallel(clowder, group_names, **kwargs):
tag = kwargs.get('tag', None)
depth = kwargs.get('depth', None)
rebase = kwargs.get('rebase', False)
protocol = kwargs.get('protocol', None)

print(' - Herd projects in parallel\n')
if project_names is None:
Expand All @@ -221,7 +228,7 @@ def herd_parallel(clowder, group_names, **kwargs):
for project in projects:
if project.name in skip:
continue
result = __clowder_pool__.apply_async(herd_project, args=(project, branch, tag, depth, rebase),
result = __clowder_pool__.apply_async(herd_project, args=(project, branch, tag, depth, rebase, protocol),
callback=async_callback)
__clowder_results__.append(result)
pool_handler(len(projects))
Expand All @@ -233,7 +240,7 @@ def herd_parallel(clowder, group_names, **kwargs):
for project in projects:
if project.name in skip:
continue
result = __clowder_pool__.apply_async(herd_project, args=(project, branch, tag, depth, rebase),
result = __clowder_pool__.apply_async(herd_project, args=(project, branch, tag, depth, rebase, protocol),
callback=async_callback)
__clowder_results__.append(result)
pool_handler(len(projects))
Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/prune_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,6 @@
from cement.ext.ext_argparse import ArgparseController, expose
from termcolor import cprint

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
existing_branch_groups,
Expand All @@ -28,6 +24,8 @@
validate_groups,
validate_projects
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.connectivity import network_connection_required


Expand Down
2 changes: 1 addition & 1 deletion clowder/clowder/cli/repo_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

from clowder.clowder_repo import (
CLOWDER_REPO,
clowder_required,
print_clowder_repo_status,
print_clowder_repo_status_fetch
)
from clowder.util.decorators import clowder_required
from clowder.util.connectivity import network_connection_required


Expand Down
8 changes: 3 additions & 5 deletions clowder/clowder/cli/reset_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,11 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.cli.parallel import reset
from clowder.clowder_repo import (
print_clowder_repo_status_fetch,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.parallel import reset
from clowder.cli.util import options_help_message
from clowder.clowder_repo import print_clowder_repo_status_fetch
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.connectivity import network_connection_required


Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/save_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@
from cement.ext.ext_argparse import ArgparseController, expose

import clowder.util.formatting as fmt
from clowder.clowder_repo import (
CLOWDER_REPO,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
validate_groups,
validate_projects_exist
)
from clowder.clowder_repo import CLOWDER_REPO
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.yaml.saving import save_yaml


Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/start_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
filter_groups,
Expand All @@ -21,6 +17,8 @@
validate_groups,
validate_projects
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.connectivity import network_connection_required


Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/stash_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,6 @@

from cement.ext.ext_argparse import ArgparseController, expose

from clowder.clowder_repo import (
print_clowder_repo_status,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.util import (
filter_groups,
Expand All @@ -21,6 +17,8 @@
run_group_command,
run_project_command
)
from clowder.clowder_repo import print_clowder_repo_status
from clowder.util.decorators import valid_clowder_yaml_required


class StashController(ArgparseController):
Expand Down
6 changes: 2 additions & 4 deletions clowder/clowder/cli/sync_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,11 @@
from cement.ext.ext_argparse import ArgparseController, expose
from termcolor import cprint

from clowder.clowder_repo import (
print_clowder_repo_status_fetch,
valid_clowder_yaml_required
)
from clowder.cli.globals import CLOWDER_CONTROLLER
from clowder.cli.parallel import sync
from clowder.cli.util import options_help_message
from clowder.clowder_repo import print_clowder_repo_status_fetch
from clowder.util.decorators import valid_clowder_yaml_required
from clowder.util.connectivity import network_connection_required


Expand Down
2 changes: 1 addition & 1 deletion clowder/clowder/cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def options_help_message(options, message):
:rtype: str
"""

if options == [''] or options is None or options == []:
if options == [''] or options is None or options == [] or not all(isinstance(n, str) for n in options):
return message

help_message = '''
Expand Down

0 comments on commit 3941b1b

Please sign in to comment.