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: add fpm_model.json to the package tarball before uploading to the registry #1010

Merged
merged 8 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/fpm/cmd/publish.f90
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ subroutine cmd_publish(settings)
end do

tmp_file = get_temp_filename()
call git_archive('.', tmp_file, 'HEAD', settings%verbose, error)
call git_archive('.', tmp_file, 'HEAD', additional_files=['fpm_model.json'], verbose=settings%verbose, error=error)
if (allocated(error)) call fpm_stop(1, '*cmd_publish* Archive error: '//error%message)
call model%dump('fpm_model.json', error, json=.true.)
if (allocated(error)) call fpm_stop(1, '*cmd_publish* Model dump error: '//error%message)
Expand Down
22 changes: 18 additions & 4 deletions src/fpm/git.f90
Original file line number Diff line number Diff line change
Expand Up @@ -407,20 +407,22 @@ pure function descriptor_name(descriptor) result(name)
end function descriptor_name

!> Archive a folder using `git archive`.
subroutine git_archive(source, destination, ref, verbose, error)
subroutine git_archive(source, destination, ref, additional_files, verbose, error)
henilp105 marked this conversation as resolved.
Show resolved Hide resolved
!> Directory to archive.
character(*), intent(in) :: source
!> Destination of the archive.
character(*), intent(in) :: destination
!> (Symbolic) Reference to be archived.
character(*), intent(in) :: ref
!> (Optional) list of additional untracked files to be added to the archive.
character(*), optional, intent(in) :: additional_files(:)
!> Print additional information if true.
logical, intent(in) :: verbose
!> Error handling.
type(error_t), allocatable, intent(out) :: error

integer :: stat
character(len=:), allocatable :: cmd_output, archive_format
integer :: stat,i
character(len=:), allocatable :: cmd_output, archive_format, add_files

call execute_and_read_output('git archive -l', cmd_output, error, verbose)
if (allocated(error)) return
Expand All @@ -431,7 +433,19 @@ subroutine git_archive(source, destination, ref, verbose, error)
call fatal_error(error, "Cannot find a suitable archive format for 'git archive'."); return
end if

call run('git archive '//ref//' --format='//archive_format//' -o '//destination, echo=verbose, exitstat=stat)
allocate(character(len=0) :: add_files)
if (present(additional_files)) then
do i=1,size(additional_files)
add_files = trim(add_files)//' --add-file='//adjustl(additional_files(i))
end do
endif

call run('git archive '//ref//' &
--format='//archive_format// &
add_files//' \
-o '//destination, \
echo=verbose, \
exitstat=stat)
if (stat /= 0) then
call fatal_error(error, "Error packing '"//source//"'."); return
end if
Expand Down
Loading