@@ -308,31 +308,51 @@ subroutine info(self, unit, verbosity)
308
308
end subroutine info
309
309
310
310
! > Archive a folder using `git archive`.
311
- subroutine git_archive (source , destination , error )
311
+ subroutine git_archive (source , destination , ref , verbose , error )
312
312
! > Directory to archive.
313
313
character (* ), intent (in ) :: source
314
314
! > Destination of the archive.
315
315
character (* ), intent (in ) :: destination
316
+ ! > (Symbolic) Reference to be archived.
317
+ character (* ), intent (in ) :: ref
318
+ ! > Whether to print verbose output.
319
+ logical , intent (in ) :: verbose
316
320
! > Error handling.
317
321
type (error_t), allocatable , intent (out ) :: error
318
322
319
323
integer :: stat
320
- character (len= :), allocatable :: cmd_output, archive_format
324
+ character (len= :), allocatable :: cmd_output, archive_format, cmd
325
+
326
+ if (verbose) then
327
+ print * , ' '
328
+ print * , ' Show git archive options:'
329
+ print * , ' + git archive -l'
330
+ end if
321
331
322
332
call execute_and_read_output(' git archive -l' , cmd_output, error)
323
333
if (allocated (error)) return
324
334
335
+ if (verbose) print * , ' ' , cmd_output
336
+
325
337
if (index (cmd_output, ' tar.gz' ) /= 0 ) then
326
338
archive_format = ' tar.gz'
327
339
else
328
340
call fatal_error(error, " Cannot find a suitable archive format for 'git archive'." ); return
329
341
end if
330
342
331
- call execute_command_line(' git archive HEAD --format=' // archive_format// ' -o ' // destination, exitstat= stat)
343
+ cmd = ' git archive ' // ref// ' --format=' // archive_format// ' -o ' // destination
344
+
345
+ if (verbose) then
346
+ print * , ' '
347
+ print * , ' Archive ' , ref, ' using ' , archive_format, ' :'
348
+ print * , ' + ' , cmd
349
+ print * , ' '
350
+ end if
351
+
352
+ call execute_command_line(cmd, exitstat= stat)
332
353
if (stat /= 0 ) then
333
354
call fatal_error(error, " Error packing '" // source// " '." ); return
334
355
end if
335
356
end
336
357
337
-
338
358
end module fpm_git
0 commit comments