@@ -149,6 +149,9 @@ def _install_galaxy_collections(
149
149
150
150
Args:
151
151
collections: The collection objects.
152
+
153
+ Raises:
154
+ SystemExit: If the collection installation fails.
152
155
"""
153
156
collections_str = " " .join (
154
157
[f"'{ collection .original } '" for collection in collections ],
@@ -187,27 +190,19 @@ def _install_galaxy_collections(
187
190
except subprocess .CalledProcessError as exc :
188
191
err = f"Failed to install collection: { exc } \n { exc .stderr } "
189
192
self ._output .critical (err )
190
- return
193
+ raise SystemError ( err ) from exc # pragma: no cover # critical exits
191
194
installed = self .RE_GALAXY_INSTALLED .findall (proc .stdout )
192
195
msg = f"Installed collections include: { oxford_join (installed )} "
193
196
self ._output .note (msg )
194
197
195
198
def _install_galaxy_requirements (self : Installer ) -> None :
196
199
"""Install the collections using requirements.yml."""
197
- if self ._config .args .requirement and not self ._config .args .cpi :
198
- msg = f"Installing collections from requirements file: { self ._config .args .requirement } "
199
- self ._output .info (msg )
200
- collections = collections_from_requirements (
201
- file = self ._config .args .requirement ,
202
- )
203
- elif self ._config .args .cpi :
204
- msg = "Source installing collections from requirements file source-requirement.yml"
205
- self ._output .info (msg )
206
- collections = collections_from_requirements (
207
- file = self ._config .args .requirement ,
208
- )
209
- else :
210
- collections = []
200
+ method = "Pre-installing" if self ._config .args .cpi else "Installing"
201
+ msg = f"{ method } collections from requirements file: { self ._config .args .requirement } "
202
+
203
+ self ._output .info (msg )
204
+
205
+ collections = collections_from_requirements (file = self ._config .args .requirement )
211
206
212
207
for collection in collections :
213
208
cnamespace = collection ["name" ].split ("." )[0 ]
@@ -312,7 +307,7 @@ def _find_files_using_ls(
312
307
313
308
def _copy_repo_files (
314
309
self : Installer ,
315
- local_repo_path : Path | None ,
310
+ local_repo_path : Path ,
316
311
destination_path : Path ,
317
312
) -> None :
318
313
"""Copy collection files tracked in git to the build directory.
@@ -321,12 +316,10 @@ def _copy_repo_files(
321
316
local_repo_path: The collection local path.
322
317
destination_path: The build destination path.
323
318
324
- """
325
- if local_repo_path is None :
326
- msg = "Invalid repo path, no files to copy"
327
- self ._output .debug (msg )
328
- return
319
+ Raises:
320
+ SystemExit: If no files are found.
329
321
322
+ """
330
323
# Get tracked files from git ls-files command
331
324
found_using , files_stdout = self ._find_files_using_git_ls_files (
332
325
local_repo_path = local_repo_path ,
@@ -340,7 +333,7 @@ def _copy_repo_files(
340
333
if not files_stdout :
341
334
msg = "No files found with either 'git ls-files' or 'ls"
342
335
self ._output .critical (msg )
343
- return
336
+ raise SystemExit ( msg ) # pragma: no cover # critical exits
344
337
345
338
msg = f"File list generated with '{ found_using } '"
346
339
self ._output .info (msg )
@@ -380,6 +373,7 @@ def _install_local_collection(
380
373
381
374
Raises:
382
375
RuntimeError: If tarball is not found or if more than one tarball is found.
376
+ SystemExit: If the collection installation fails.
383
377
"""
384
378
msg = f"Installing local collection from: { collection .build_dir } "
385
379
self ._output .info (msg )
@@ -464,7 +458,7 @@ def _install_local_collection(
464
458
except subprocess .CalledProcessError as exc :
465
459
err = f"Failed to install collection: { exc } { exc .stderr } "
466
460
self ._output .critical (err )
467
- return
461
+ raise SystemError ( err ) from exc # pragma: no cover # critical exits
468
462
469
463
# ansible-galaxy collection install does not include the galaxy.yml for version
470
464
# nor does it create an info file that can be used to determine the version.
@@ -490,15 +484,10 @@ def _swap_editable_collection(self: Installer, collection: Collection) -> None:
490
484
Args:
491
485
collection: The collection object.
492
486
493
- Raises:
494
- RuntimeError: If the collection path is not set.
495
487
"""
496
488
msg = f"Swapping { collection .name } with { collection .path } "
497
489
self ._output .info (msg )
498
490
499
- if collection .path is None :
500
- msg = "Collection path not set"
501
- raise RuntimeError (msg )
502
491
msg = f"Removing installed { collection .site_pkg_path } "
503
492
self ._output .debug (msg )
504
493
if collection .site_pkg_path .exists ():
0 commit comments