Skip to content

Commit

Permalink
Merge pull request #491 from JrGoodle/default-project-path
Browse files Browse the repository at this point in the history
Update default project path to last name component
  • Loading branch information
JrGoodle committed May 15, 2020
2 parents 2b75c04 + aa4b8da commit a8aa2a6
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 8 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ examples/cats/peru.yaml
examples/cats/black*
examples/cats/mu
examples/cats/duke
examples/cats/kit
examples/cats/kishka
examples/cats/june
examples/cats/sasha
examples/cats/polkabot
examples/cats/videos
examples/cats/jrgoodle
Expand Down
4 changes: 4 additions & 0 deletions examples/cats/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,9 @@ rm -rf .clowder
rm -rf black-cats
rm -rf duke
rm -rf mu
rm -rf kit
rm -rf kishka
rm -rf june
rm -rf sasha
rm -rf jrgoodle
rm -f clowder.yaml
2 changes: 1 addition & 1 deletion src/clowder/model/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self, project: dict, defaults: Defaults, sources: List[Source]):
"""

self.name = project['name']
self.path = project.get('path', self.name)
self.path = project.get('path', fmt.last_path_component(self.name))
self.remote = project.get('remote', defaults.remote)
self.depth = project.get('depth', defaults.depth)
self.recursive = project.get('recursive', defaults.recursive)
Expand Down
12 changes: 12 additions & 0 deletions src/clowder/util/formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"""

import os
from typing import Optional

# noinspection PyPackageRequirements
Expand Down Expand Up @@ -303,6 +304,17 @@ def fork_string(name: str) -> str:
return colored(name, 'cyan')


def last_path_component(path: str) -> str:
"""Return last path component
:param str path: Path string
:return: Last path component
:rtype: str
"""

return os.path.basename(os.path.normpath(path))


def path_string(path: str) -> str:
"""Return formatted path
Expand Down
2 changes: 1 addition & 1 deletion src/clowder/util/yaml.py
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ def _validate_yaml_contents(yaml: dict, yaml_file: str) -> None:
projects_with_forks = []
for p in yaml['projects']:
project = {'name': p['name'],
'path': p.get('path', p['name'])}
'path': p.get('path', fmt.last_path_component(p['name']))}
if 'remote' in p:
project['remote'] = p['remote']
if 'source' in p:
Expand Down
12 changes: 6 additions & 6 deletions test/scripts/cats/herd.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,22 @@ test_herd_implicit_project_paths() {
echo "TEST: Check projects are on correct branches with implicit project paths"
$COMMAND link -v implicit-paths || exit 1
$COMMAND herd $PARALLEL || exit 1
pushd jrgoodle/mu || exit 1
pushd mu || exit 1
test_branch knead
popd || exit 1
pushd jrgoodle/duke || exit 1
pushd duke || exit 1
test_branch purr
popd || exit 1
pushd jrgoodle/kit || exit 1
pushd kit || exit 1
test_branch master
popd || exit 1
pushd jrgoodle/kishka || exit 1
pushd kishka || exit 1
test_branch master
popd || exit 1
pushd jrgoodle/sasha || exit 1
pushd sasha || exit 1
test_branch master
popd || exit 1
pushd jrgoodle/june || exit 1
pushd june || exit 1
test_branch master
popd || exit 1
}
Expand Down

0 comments on commit a8aa2a6

Please sign in to comment.