Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix role name handling in prerun.py #1490

Merged
merged 13 commits into from Apr 7, 2021
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions playbooks/eco.yml
Expand Up @@ -8,6 +8,11 @@
- name: ansible-role-mysql
url: https://github.com/geerlingguy/ansible-role-mysql.git
contact: geerlingguy
- name: geerlingguy.mysql
ssbarnea marked this conversation as resolved.
Show resolved Hide resolved
url: https://github.com/geerlingguy/ansible-role-mysql.git
contact: geerlingguy
# duplicates first one but covers for the case where clone is made in a
# folder that uses namespace.rolename pattern (installed galaxy role)
- name: zuul-jobs
url: https://opendev.org/zuul/zuul-jobs
contact: ssbarnea
Expand Down
4 changes: 2 additions & 2 deletions src/ansiblelint/prerun.py
Expand Up @@ -169,7 +169,7 @@ def _install_galaxy_role() -> 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:
if not role_name or os.path.exists(".git") or os.path.exists(".hg"):
apatard marked this conversation as resolved.
Show resolved Hide resolved
role_name = pathlib.Path(".").absolute().name
role_name = re.sub(r'^{0}'.format(re.escape('ansible-role-')), '', role_name)

Expand Down Expand Up @@ -202,7 +202,7 @@ def _install_galaxy_role() -> None:
fqrn = role_name
p = pathlib.Path(f"{options.project_dir}/.cache/roles")
p.mkdir(parents=True, exist_ok=True)
link_path = p / f"{role_namespace}.{role_name}"
link_path = p / fqrn
ssbarnea marked this conversation as resolved.
Show resolved Hide resolved
# 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