Skip to content

Commit

Permalink
Automatically add --pre when installing collections from git reposito…
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea authored Sep 5, 2023
1 parent 01c91c6 commit 0181df0
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions examples/reqs_v2/requirements.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,13 @@ roles:
name: geerlingguy.mysql
collections:
- name: community-molecule-0.1.0.tar.gz
# Also needed for testing purposes as this should trigger addition of --pre
# argument as this is required due to
# https://github.com/ansible/ansible-lint/issues/3686
# https://github.com/ansible/ansible/issues/79109
- name: https://github.com/ansible-collections/amazon.aws.git
type: git
version: main
- name: https://github.com/ansible-collections/community.aws.git
type: git
version: main
7 changes: 7 additions & 0 deletions src/ansible_compat/runtime.py
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,13 @@ def install_requirements( # noqa: C901
"install",
"-v",
]
for collection in reqs_yaml["collections"]:
if isinstance(collection, dict) and collection.get("type", "") == "git":
_logger.info(
"Adding '--pre' to ansible-galaxy collection install because we detected one collection being sourced from git.",
)
cmd.append("--pre")
break
if offline:
_logger.warning(
"Skipped installing collection dependencies due to running in offline mode.",
Expand Down

0 comments on commit 0181df0

Please sign in to comment.