Skip to content

Commit

Permalink
Merge pull request #503 from JrGoodle/positional-args
Browse files Browse the repository at this point in the history
Convert commands to use positional args
  • Loading branch information
JrGoodle committed May 18, 2020
2 parents fbd42fb + 2f48bd6 commit 3f06f7c
Show file tree
Hide file tree
Showing 96 changed files with 1,572 additions and 2,005 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ clowder clean # Discard any changes in projects
clowder diff # Print git diff for all projects
clowder forall -c 'git status' # Run command in all project directories
clowder herd -b my_branch # Herd a specified branch if it exists, otherwise use default ref
clowder link -v 0.1 # Set clowder.yaml symlink to a previously saved version
clowder link 0.1 # Set clowder.yaml symlink to a previously saved version
clowder repo run 'git status' # Run command in .clowder directory
clowder save 0.1 # Save a version of clowder.yaml with current commit sha's
clowder start my_feature # Create new branch 'my_feature' for all projects
Expand Down
1 change: 0 additions & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ test_script:
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app reset --parallel
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app prune new_branch
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app save vWin
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app sync --parallel
- coverage run --rcfile=%APPVEYOR_BUILD_FOLDER%\.coveragerc -m clowder.clowder_app yaml

after_test:
Expand Down
5 changes: 3 additions & 2 deletions clowder_test/clowder_test/execute.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def execute_test_command(command: str, path: str, parallel: bool = False, write:
else:
test_env['COMMAND'] = 'clowder'

if debug:
test_env['COMMAND'] = test_env['COMMAND'] + ' --debug'
# TODO: Remove this since cement is no longer used?
# if debug:
# test_env['COMMAND'] = test_env['COMMAND'] + ' --debug'

if quiet:
test_env['COMMAND'] = test_env['COMMAND'] + ' --quiet'
Expand Down
2 changes: 1 addition & 1 deletion docs/clowder-repo.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ The "clowder repo" is a git repository cloned into the `.clowder` directory when

A `versions` directory can contain versioned `clowder.yaml` files. These can be symlinked with the `clowder link -v` command

For example, `versions/my_version.yaml` would by symlinked by running `clowder link -v my_version`
For example, `versions/my_version.yaml` would by symlinked by running `clowder link my_version`
42 changes: 21 additions & 21 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ clowder branch -r
clowder branch -a

# Print local branches in llvm group
clowder branch -p llvm
clowder branch llvm

# Print local branches in swift project
clowder branch -p apple/swift
clowder branch apple/swift
```

---
Expand All @@ -32,10 +32,10 @@ clowder branch -p apple/swift
clowder checkout branch_name

# Checkout branches in llvm group
clowder checkout branch_name -p llvm
clowder checkout branch_name llvm

# Checkout branches in swift project
clowder checkout branch_name -p apple/swift
clowder checkout branch_name apple/swift
```

---
Expand All @@ -59,10 +59,10 @@ clowder clean
clowder clean -a

# Discard changes in projects in llvm group
clowder clean -p llvm
clowder clean llvm

# Discard changes in swift project
clowder clean -p apple/swift
clowder clean apple/swift

# Remove untracked directories in addition to untracked files
# Equivalent to:
Expand Down Expand Up @@ -104,10 +104,10 @@ Equivalent to running `git status -vv` in project directories
clowder diff

# Print git diff status for projects in llvm group
clowder diff -p llvm
clowder diff llvm

# Print git diff status for swift project
clowder diff -p apple/swift
clowder diff apple/swift
```

---
Expand Down Expand Up @@ -136,10 +136,10 @@ clowder forall -c "git status" -g llvm
clowder forall -c "/path/to/script.sh" -g llvm

# Run command for swift project
clowder forall -c "git status" -p apple/swift
clowder forall apple/swift -c "git status"

# Run script for swift project
clowder forall -c "/path/to/script.sh" -p apple/swift
clowder forall apple/swift -c "/path/to/script.sh"
```

The following environment variables are available for use in commands and scripts:
Expand Down Expand Up @@ -176,10 +176,10 @@ clowder herd -b my_branch
clowder herd -t my_tag

# Only herd projects in swift and llvm groups
clowder herd -p swift llvm
clowder herd swift llvm

# Only herd swift project
clowder herd -p apple/swift
clowder herd apple/swift
```

---
Expand Down Expand Up @@ -207,7 +207,7 @@ Set `clowder.yaml` symlink
clowder link

# Point clowder.yaml symlink to saved version
clowder link -v 0.1
clowder link 0.1
```

---
Expand All @@ -233,10 +233,10 @@ clowder prune -a stale_branch
clowder prune -af stale_branch

# Prune branch 'stale_branch' for projects in llvm group
clowder prune stale_branch -p llvm
clowder prune stale_branch llvm

# Prune branch 'stale_branch' in swift project
clowder prune stale_branch -p apple/swift
clowder prune stale_branch apple/swift
```

---
Expand Down Expand Up @@ -287,10 +287,10 @@ clowder reset
clowder reset --timestamp apple/swift

# Reset branches in projects in llvm group
clowder reset -p llvm
clowder reset llvm

# Reset branches in swift project
clowder reset -p apple/swift
clowder reset apple/swift
```

---
Expand Down Expand Up @@ -320,10 +320,10 @@ clowder start my_feature
clowder start -t my_feature

# Create new local branch 'my_feature' for projects in llvm group
clowder start my_feature -p llvm
clowder start my_feature llvm

# Create new local branch 'my_feature' in swift project
clowder start my_feature -p apple/swift
clowder start my_feature apple/swift
```

---
Expand All @@ -337,10 +337,10 @@ Stash changes in dirty repositories
clowder stash

# Stash changes in projects in llvm group
clowder stash -p llvm
clowder stash llvm

# Stash changes in swift project
clowder stash -p apple/swift
clowder stash apple/swift
```

---
Expand Down
2 changes: 1 addition & 1 deletion docs/swift-update-checkout-py.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,6 @@ swift/utils/update-checkout --scheme swift-4.0-branch --match-timestamp

```bash
# Assuming repos were previously cloned
clowder link -v swift-4.0-branch
clowder link swift-4.0-branch
clowder reset --timestamp apple/swift
```
2 changes: 1 addition & 1 deletion script/ci_after
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ coverage combine --append \

## Codecov ##
echo 'Upload codecov results'
bash <(curl -s https://codecov.io/bash) -X gcov
bash <(curl -s https://codecov.io/bash) -X gcov || echo "Codecov did not collect coverage reports"
# echo 'Upload workflow coverage results to s3'
# cp .coverage "coverage/codecov/${COVERAGE_FILE}"
# aws s3 sync coverage/codecov/ "${S3_PATH}/codecov"
Expand Down
2 changes: 1 addition & 1 deletion script/update
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [ "$1" == 'version' ]; then
NEW_VERSION=$2

perl -pi -e "s/$OLD_VERSION/$NEW_VERSION/g" src/setup.py || exit 1
perl -pi -e "s/$OLD_VERSION/$NEW_VERSION/g" src/clowder/cli/base_controller.py || exit 1
perl -pi -e "s/$OLD_VERSION/$NEW_VERSION/g" src/clowder/clowder_app.py || exit 1
perl -pi -e "s/$OLD_VERSION/$NEW_VERSION/g" .github/issue_template.md || exit 1
perl -pi -e "s/$OLD_VERSION/$NEW_VERSION/g" docs/conf.py || exit 1
exit
Expand Down
3 changes: 1 addition & 2 deletions src/clowder/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
CLOWDER_SCHEMA = pkg_resources.resource_string(__name__, "clowder.schema.json")


CURRENT_DIR: str = os.getcwd()
CURRENT_DIR = os.getcwd()
CLOWDER_DIR: Optional[str] = None
CLOWDER_REPO_DIR: Optional[str] = None
CLOWDER_REPO_VERSIONS_DIR: Optional[str] = None
Expand Down Expand Up @@ -42,4 +42,3 @@
clowder_versions = os.path.join(CLOWDER_REPO_DIR, 'versions')
if os.path.isdir(clowder_versions):
CLOWDER_REPO_VERSIONS_DIR = clowder_versions

44 changes: 16 additions & 28 deletions src/clowder/cli/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,19 @@
"""

from clowder.cli.base_controller import BaseController
from clowder.cli.branch_controller import BranchController
from clowder.cli.checkout_controller import CheckoutController
from clowder.cli.clean_controller import CleanController
from clowder.cli.diff_controller import DiffController
from clowder.cli.forall_controller import ForallController
from clowder.cli.herd_controller import HerdController
from clowder.cli.init_controller import InitController
from clowder.cli.link_controller import LinkController
from clowder.cli.prune_controller import PruneController
from clowder.cli.repo_controller import (
RepoCheckoutController,
RepoCleanController,
RepoController,
RepoAddController,
RepoCommitController,
RepoRunController,
RepoPullController,
RepoPushController,
RepoStatusController
)
from clowder.cli.reset_controller import ResetController
from clowder.cli.save_controller import SaveController
from clowder.cli.start_controller import StartController
from clowder.cli.stash_controller import StashController
from clowder.cli.status_controller import StatusController
from clowder.cli.sync_controller import SyncController
from clowder.cli.yaml_controller import YAMLController
from clowder.cli.branch import add_branch_parser
from clowder.cli.checkout import add_checkout_parser
from clowder.cli.clean import add_clean_parser
from clowder.cli.diff import add_diff_parser
from clowder.cli.forall import add_forall_parser
from clowder.cli.herd import add_herd_parser
from clowder.cli.init import add_init_parser
from clowder.cli.link import add_link_parser
from clowder.cli.prune import add_prune_parser
from clowder.cli.repo import add_repo_parser
from clowder.cli.reset import add_reset_parser
from clowder.cli.save import add_save_parser
from clowder.cli.start import add_start_parser
from clowder.cli.stash import add_stash_parser
from clowder.cli.status import add_status_parser
from clowder.cli.yaml import add_yaml_parser
23 changes: 0 additions & 23 deletions src/clowder/cli/base_controller.py

This file was deleted.

57 changes: 57 additions & 0 deletions src/clowder/cli/branch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
"""Clowder command line branch controller
.. codeauthor:: Joe Decapo <joe@polka.cat>
"""

import argparse

from clowder.clowder_controller import CLOWDER_CONTROLLER
from clowder.util.clowder_utils import (
add_parser_arguments,
filter_projects,
options_help_message
)
from clowder.util.decorators import (
print_clowder_repo_status,
valid_clowder_yaml_required
)


def add_branch_parser(subparsers: argparse._SubParsersAction) -> None: # noqa

arguments = [
(['projects'], dict(metavar='PROJECT', default='all', nargs='*', choices=CLOWDER_CONTROLLER.project_choices,
help=options_help_message(CLOWDER_CONTROLLER.project_names,
'projects and groups to show branches for'))),
(['--all', '-a'], dict(action='store_true', help='show local and remote branches')),
(['--remote', '-r'], dict(action='store_true', help='show remote branches'))
]

parser = subparsers.add_parser('branch', help='Display current branches')
add_parser_arguments(parser, arguments)
parser.set_defaults(func=branch)


def branch(args) -> None:
"""Clowder branch command entry point"""
_branch(args)


@valid_clowder_yaml_required
@print_clowder_repo_status
def _branch(args) -> None:
"""Clowder branch command private implementation"""
local = True
remote = False
if args.all:
local = True
remote = True
elif args.remote:
remote = True

projects = filter_projects(CLOWDER_CONTROLLER.projects, args.projects)
for project in projects:
print(project.status())
project.branch(local=local, remote=remote)

0 comments on commit 3f06f7c

Please sign in to comment.