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

add git dependencies with submodules #816

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
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
20 changes: 18 additions & 2 deletions src/fpm/git.f90
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
!> Implementation for interacting with git repositories.
module fpm_git
use fpm_error, only: error_t, fatal_error
use fpm_filesystem, only : get_temp_filename, getline, join_path
use fpm_filesystem, only : get_temp_filename, getline, join_path, exists
use fpm_os, only : get_current_directory, change_directory
implicit none

public :: git_target_t
Expand Down Expand Up @@ -141,7 +142,7 @@ subroutine checkout(self, local_path, error)
type(error_t), allocatable, intent(out) :: error

integer :: stat
character(len=:), allocatable :: object, workdir
character(len=:), allocatable :: object, workdir, cwd

if (allocated(self%object)) then
object = self%object
Expand Down Expand Up @@ -172,6 +173,21 @@ subroutine checkout(self, local_path, error)
return
end if

! cd into the git_dir, update existing submodules and cd back
call get_current_directory(cwd, error)
if (allocated(error)) return
call change_directory(local_path, error)
if (allocated(error)) return
if (exists(".gitmodules")) then
call execute_command_line("git submodule update --init --recursive", exitstat=stat)
if (stat /= 0) then
call fatal_error(error,'Error while updating git submodules for remote dependency')
return
end if
end if
call change_directory(cwd, error)
if (allocated(error)) return

end subroutine checkout


Expand Down