Skip to content

Commit daa0e69

Browse files
committed
Fix Git sub-modules handling
Add init and update of Git sub-modules when cloning a specific revision. This is used by the `nimble sync` command when downloading locked dependencies. Without it required by some libraries, additional files will not be installed. This for example is the case with the `nim-bearssl` library. Fixes #958
1 parent 26c9102 commit daa0e69

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/nimblepkg/download.nim

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,18 @@ type
1515
version: Version
1616
vcsRevision: Sha1Hash
1717

18+
proc updateSubmodules(dir: string) =
19+
discard tryDoCmdEx(
20+
&"git -C {dir} submodule update --init --recursive --depth 1")
21+
1822
proc doCheckout(meth: DownloadMethod, downloadDir, branch: string) =
1923
case meth
2024
of DownloadMethod.git:
2125
# Force is used here because local changes may appear straight after a clone
2226
# has happened. Like in the case of git on Windows where it messes up the
2327
# damn line endings.
24-
discard tryDoCmdEx(&"git -C {downloadDir} checkout --force {branch}")
25-
discard tryDoCmdEx(
26-
&"git -C {downloadDir} submodule update --recursive --depth 1")
28+
discard tryDoCmdEx(&"git -C {downloadDir} checkout --force {branch}")
29+
downloadDir.updateSubmodules
2730
of DownloadMethod.hg:
2831
discard tryDoCmdEx(&"hg --cwd {downloadDir} checkout {branch}")
2932

@@ -147,6 +150,7 @@ proc cloneSpecificRevision(downloadMethod: DownloadMethod,
147150
discard tryDoCmdEx(
148151
&"git -C {downloadDir} fetch --depth 1 origin {vcsRevision}")
149152
discard tryDoCmdEx(&"git -C {downloadDir} reset --hard FETCH_HEAD")
153+
downloadDir.updateSubmodules
150154
of DownloadMethod.hg:
151155
discard tryDoCmdEx(&"hg clone {url} -r {vcsRevision}")
152156

0 commit comments

Comments
 (0)