Skip to content

Commit

Permalink
Merge branch 'master' into 0/x
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Mar 10, 2021
2 parents ed4bc87 + 56eb5b3 commit b292695
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/ansiblelint/_prerun.py
Expand Up @@ -154,11 +154,13 @@ def _install_galaxy_role() -> None:
if 'galaxy_info' not in yaml:
return
role_name = yaml['galaxy_info'].get('role_name', None)
role_author = yaml['galaxy_info'].get('author', None)
role_namespace = yaml['galaxy_info'].get('namespace', None)
if not role_namespace:
role_namespace = yaml['galaxy_info'].get('author', None)
if not role_name:
role_name = pathlib.Path(".").absolute().name
role_name = re.sub(r'^{0}'.format(re.escape('ansible-role-')), '', role_name)
fqrn = f"{role_author}.{role_name}"
fqrn = f"{role_namespace}.{role_name}"
if not re.match(r"[a-z0-9][a-z0-9_]+\.[a-z][a-z0-9_]+$", fqrn):
print(
f"""\
Expand All @@ -167,7 +169,7 @@ def _install_galaxy_role() -> None:
galaxy_info:
role_name: my_name # if absent directory name hosting role is used instead
author: my_galaxy_namespace
namespace: my_galaxy_namespace # if absent, author is used instead
Namespace: https://galaxy.ansible.com/docs/contributing/namespaces.html#galaxy-namespace-limitations
Role: https://galaxy.ansible.com/docs/contributing/creating_role.html#role-names
Expand All @@ -177,7 +179,7 @@ def _install_galaxy_role() -> None:
sys.exit(INVALID_PREREQUISITES_RC)
p = pathlib.Path(f"{options.project_dir}/.cache/roles")
p.mkdir(parents=True, exist_ok=True)
link_path = p / f"{role_author}.{role_name}"
link_path = p / f"{role_namespace}.{role_name}"
# despite documentation stating that is_file() reports true for symlinks,
# it appears that is_dir() reports true instead, so we rely on exits().
if not link_path.exists():
Expand Down

0 comments on commit b292695

Please sign in to comment.