Skip to content

Commit

Permalink
Merge pull request #474 from JrGoodle/remove-alias
Browse files Browse the repository at this point in the history
Remove alias
  • Loading branch information
JrGoodle committed May 10, 2020
2 parents 87f8147 + 0e3cdaa commit 4362574
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 62 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
[![Documentation Status](https://readthedocs.org/projects/clowder/badge/?version=latest)](http://clowder.readthedocs.io)

> **clowder** - A group of cats
> **herding cats** - An idiom that refers to a frustrating attempt to control or organize a class of entities which are uncontrollable or chaotic
Managing multiple repositories can be pretty frustrating. There are a number of existing options:
Expand Down
1 change: 0 additions & 1 deletion src/clowder/error/clowder_yaml_error.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ class ClowderYAMLYErrorType(IntEnum):
SOURCE_NOT_FOUND = 114
GROUPS_CONTAINS_ALL = 115
DUPLICATE_PATH = 116
DUPLICATE_ALIAS = 117
29 changes: 3 additions & 26 deletions src/clowder/model/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class Project(object):
"""clowder.yaml Project model class
:ivar str name: Project name
:ivar Optional[str] alias: Alias for project
:ivar str path: Project relative path
:ivar List[str] groups: Groups project belongs to
:ivar str ref: Project git ref
Expand All @@ -69,7 +68,6 @@ def __init__(self, project: dict, defaults: Defaults, sources: List[Source]):

self.name = project['name']
self.path = project['path']
self.alias = project.get('alias', None)
self.ref = project.get('ref', defaults.ref)
self.remote = project.get('remote', defaults.remote)
self.depth = project.get('depth', defaults.depth)
Expand All @@ -83,9 +81,6 @@ def __init__(self, project: dict, defaults: Defaults, sources: List[Source]):
groups += custom_groups
if 'notdefault' in groups:
groups.remove('all')
if self.alias:
groups.append(self.alias)
groups.remove(self.name)
self.groups = list(set(groups))

self.source = None
Expand Down Expand Up @@ -255,9 +250,6 @@ def get_yaml(self, resolved: bool = False) -> dict:
'remote': self.remote,
'source': self.source.name}

if self.alias:
project['alias'] = self.alias

if self.fork:
fork_yaml = self.fork.get_yaml()
project['fork'] = fork_yaml
Expand Down Expand Up @@ -295,7 +287,7 @@ def herd(self, branch: Optional[str] = None, tag: Optional[str] = None, depth: O
self._print(self.fork.status())
repo.configure_remotes(self.remote, self._url(), self.fork.remote, self.fork.url())

self._print(fmt.fork_string(self.output_name()))
self._print(fmt.fork_string(self.name))
# Modify repo to prefer fork
repo.default_ref = self.fork.ref
repo.remote = self.fork.remote
Expand Down Expand Up @@ -330,18 +322,6 @@ def is_valid(self) -> bool:

return ProjectRepo(self.full_path(), self.remote, self.ref).validate_repo()

def output_name(self) -> str:
"""Name to use for output
:return: Alias if set, otherwise project name
:rtype: str
"""

if self.alias:
return self.alias

return self.name

def print_existence_message(self) -> None:
"""Print existence validation message for project"""

Expand Down Expand Up @@ -403,7 +383,7 @@ def reset(self, timestamp: Optional[str] = None, parallel: bool = False) -> None
self._print(self.fork.status())
repo.configure_remotes(self.remote, self._url(), self.fork.remote, self.fork.url())

self._print(fmt.fork_string(self.output_name()))
self._print(fmt.fork_string(self.name))
if timestamp:
repo.reset_timestamp(timestamp, self._timestamp_author, self.ref)
return
Expand All @@ -430,9 +410,6 @@ def run(self, commands: List[str], ignore_errors: bool, parallel: bool = False)
'PROJECT_REMOTE': self.remote,
'PROJECT_REF': self.ref}

if self.alias:
forall_env['PROJECT_ALIAS'] = self.alias

if self.fork:
forall_env['FORK_REMOTE'] = self.fork.remote
forall_env['FORK_NAME'] = self.fork.name
Expand Down Expand Up @@ -463,7 +440,7 @@ def status(self, padding: Optional[int] = None) -> str:
"""

if not existing_git_repository(self.full_path()):
return colored(self.output_name(), 'green')
return colored(self.name, 'green')

repo = ProjectRepo(self.full_path(), self.remote, self.ref)
project_output = repo.format_project_string(self.path)
Expand Down
12 changes: 0 additions & 12 deletions src/clowder/util/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,18 +66,6 @@ def depth_error(depth: int, yml: str) -> str:
return output_1 + output_2


def duplicate_project_name_alias_error(name: str, yml: str) -> str:
"""Return formatted error string for duplicate project name/alias
:param str name: Duplicate project alias/name
:param str yml: Path to yaml file
:return: Formatted duplicate remote fork name error
:rtype: str
"""

return yaml_path(yml) + colored(' - Error: Multiple projects with name/alias ', 'red') + colored(name, attrs=['bold'])


def duplicate_project_path_error(path: str, yml: str) -> str:
"""Return formatted error string for duplicate project path
Expand Down
17 changes: 1 addition & 16 deletions src/clowder/util/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ def validate_yaml_contents(yaml: dict, yaml_file: str) -> None:
for p in yaml['projects']:
project = {'name': p['name'],
'path': p.get('path', p['name'])}
if 'alias' in p:
project['alias'] = p['alias']
if 'remote' in p:
project['remote'] = p['remote']
if 'source' in p:
Expand Down Expand Up @@ -112,19 +110,6 @@ def validate_yaml_contents(yaml: dict, yaml_file: str) -> None:
message = fmt.duplicate_project_path_error(duplicate, yaml_file)
raise ClowderYAMLError(message, ClowderYAMLYErrorType.DUPLICATE_PATH)

# Validate projects have unique name/alias
# names = [p['alias'] if 'alias' in p else p['name'] for p in projects]
names = []
for project in projects:
if 'alias' in project:
names.append(project['alias'])
else:
names.append(project['name'])
duplicate = _check_for_duplicates(names)
if duplicate is not None:
message = fmt.duplicate_project_name_alias_error(duplicate, yaml_file)
raise ClowderYAMLError(message, ClowderYAMLYErrorType.DUPLICATE_ALIAS)


def validate_yaml_defaults(defaults: dict, yaml_file: str) -> None:
"""Validate defaults in clowder loaded from yaml file
Expand Down Expand Up @@ -185,7 +170,7 @@ def validate_yaml_projects(projects: dict, yaml_file: str) -> None:
_validate_required_string(project, 'project', 'name', yaml_file)
_validate_required_string(project, 'project', 'path', yaml_file)

args = ['alias', 'remote', 'source', 'timestamp_author']
args = ['remote', 'source', 'timestamp_author']
for arg in args:
_validate_optional_string(project, arg, yaml_file)

Expand Down
2 changes: 0 additions & 2 deletions test/scripts/cats/yaml_validation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ test_invalid_yaml() {
_test_invalid_yaml 'ls -d test-arg-type-timestamp*' '112'
_test_invalid_yaml 'ls -d test-source-not-found*' '114'
_test_invalid_yaml 'ls -d test-duplicate-project-directories*' '116'
_test_invalid_yaml 'ls -d test-duplicate-alias*' '117'
_test_invalid_yaml 'ls -d test-duplicate-name*' '117'

$COMMAND repo checkout master || exit 1
pushd .clowder || exit 1
Expand Down
5 changes: 0 additions & 5 deletions test/scripts/test_forall_script_env_fork.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ if [ $PROJECT_REF != "refs/heads/master" ]; then
exit 1
fi

echo "PROJECT_ALIAS = $PROJECT_ALIAS"
if [ $PROJECT_ALIAS != "gyp" ]; then
exit 1
fi

echo "FORK_REMOTE = $FORK_REMOTE"
if [ -z "$FORK_REMOTE" ]; then
exit 1
Expand Down

0 comments on commit 4362574

Please sign in to comment.