@@ -215,30 +215,24 @@ def _install_galaxy_requirements(self: Installer) -> None:
215
215
msg = f"Source installed collections include: { oxford_join (installed )} "
216
216
self ._output .note (msg )
217
217
218
- def _copy_git_repo_files (
218
+ def _copy_files_using_git_ls_files (
219
219
self : Installer ,
220
220
local_repo_path : Path | None ,
221
- destination_path : Path ,
222
- ) -> None :
223
- """Copy collection files tracked in git to the build directory.
221
+ ) -> str | None :
222
+ """Copy collection files tracked using git ls-files to the build directory.
224
223
225
224
Args:
226
225
local_repo_path: The collection local path.
227
- destination_path: The build destination path.
228
-
226
+ Returns:
227
+ string containing a list of files or nothing
229
228
"""
230
- if local_repo_path is None :
231
- msg = "Invalid repo path, no files to copy from Git"
232
- self ._output .info (msg )
233
- return
234
-
235
229
msg = "List collection files using git ls-files."
236
230
self ._output .debug (msg )
237
231
238
232
try :
239
233
# Get the list of tracked files in the repository
240
234
tracked_files_output = subprocess_run (
241
- command = "git ls-files 2> /dev/null || ls " ,
235
+ command = "git ls-files 2> /dev/null" ,
242
236
cwd = local_repo_path ,
243
237
verbose = self ._config .args .verbose ,
244
238
msg = msg ,
@@ -247,10 +241,76 @@ def _copy_git_repo_files(
247
241
except subprocess .CalledProcessError as exc :
248
242
err = f"Failed to list collection using git ls-files: { exc } { exc .stderr } "
249
243
self ._output .critical (err )
244
+
245
+ return tracked_files_output .stdout
246
+
247
+ def _copy_files_using_ls (
248
+ self : Installer ,
249
+ local_repo_path : Path | None ,
250
+ ) -> str | None :
251
+ """Copy collection files tracked using ls to the build directory.
252
+
253
+ Args:
254
+ local_repo_path: The collection local path.
255
+ Returns:
256
+ string containing a list of files or nothing
257
+ """
258
+ msg = "List collection files using ls."
259
+ self ._output .debug (msg )
260
+
261
+ try :
262
+ # Get the list of tracked files in the repository
263
+ tracked_files_output = subprocess_run (
264
+ command = "ls 2> /dev/null" ,
265
+ cwd = local_repo_path ,
266
+ verbose = self ._config .args .verbose ,
267
+ msg = msg ,
268
+ output = self ._output ,
269
+ )
270
+ except subprocess .CalledProcessError as exc :
271
+ err = f"Failed to list collection using ls: { exc } { exc .stderr } "
272
+ self ._output .critical (err )
273
+
274
+ return tracked_files_output .stdout
275
+
276
+ def _copy_repo_files (
277
+ self : Installer ,
278
+ local_repo_path : Path | None ,
279
+ destination_path : Path ,
280
+ ) -> None :
281
+ """Copy collection files tracked in git to the build directory.
282
+
283
+ Args:
284
+ local_repo_path: The collection local path.
285
+ destination_path: The build destination path.
286
+
287
+ """
288
+ if local_repo_path is None :
289
+ msg = "Invalid repo path, no files to copy"
290
+ self ._output .info (msg )
291
+ return
292
+
293
+ # Get tracked files from git ls-files command
294
+ tracked_files_output = self ._copy_files_using_git_ls_files (
295
+ local_repo_path = local_repo_path ,
296
+ )
297
+
298
+ if tracked_files_output is None :
299
+ msg = "No tracked files found using git ls-files"
300
+ self ._output .info (msg )
301
+
302
+ # If no tracked files found, get files using ls command
303
+ tracked_files_output = self ._copy_files_using_ls (
304
+ local_repo_path = local_repo_path ,
305
+ )
306
+
307
+ if tracked_files_output is None :
308
+ msg = "No files found"
309
+ self ._output .info (msg )
250
310
return
251
311
252
- # Get the list of tracked files
253
- tracked_files = tracked_files_output .stdout . split ("\n " )
312
+ # Parse tracked files output
313
+ tracked_files = tracked_files_output .split ("\n " )
254
314
255
315
# Create the destination folder if it doesn't exist
256
316
Path (destination_path ).mkdir (parents = True , exist_ok = True )
@@ -289,7 +349,7 @@ def _install_local_collection(
289
349
msg = f"Installing local collection from: { collection .build_dir } "
290
350
self ._output .info (msg )
291
351
292
- self ._copy_git_repo_files (
352
+ self ._copy_repo_files (
293
353
local_repo_path = collection .path ,
294
354
destination_path = collection .build_dir ,
295
355
)
0 commit comments