@@ -19,37 +19,40 @@ proc updateSubmodules(dir: string) =
19
19
discard tryDoCmdEx (
20
20
& " git -C { dir} submodule update --init --recursive --depth 1 " )
21
21
22
- proc doCheckout * (meth: DownloadMethod , downloadDir, branch: string ) =
22
+ proc doCheckout * (meth: DownloadMethod , downloadDir, branch: string , options: Options ) =
23
23
case meth
24
24
of DownloadMethod .git:
25
25
# Force is used here because local changes may appear straight after a clone
26
26
# has happened. Like in the case of git on Windows where it messes up the
27
27
# damn line endings.
28
28
discard tryDoCmdEx (& " git -C { downloadDir} checkout --force { branch} " )
29
- downloadDir.updateSubmodules
29
+ if not options.ignoreSubmodules:
30
+ downloadDir.updateSubmodules
30
31
of DownloadMethod .hg:
31
32
discard tryDoCmdEx (& " hg --cwd { downloadDir} checkout { branch} " )
32
33
33
34
proc doClone (meth: DownloadMethod , url, downloadDir: string , branch = " " ,
34
- onlyTip = true ) =
35
+ onlyTip = true , options: Options ) =
35
36
case meth
36
37
of DownloadMethod .git:
37
38
let
39
+ submoduleFlag = if not options.ignoreSubmodules: " --recurse-submodules" else : " "
38
40
depthArg = if onlyTip: " --depth 1" else : " "
39
41
branchArg = if branch == " " : " " else : & " -b { branch} "
40
42
discard tryDoCmdEx (
41
- " git clone --config core.autocrlf=false --config core.eol=lf --recursive " &
42
- & " { depthArg} { branchArg} { url} { downloadDir} " )
43
+ " git clone --config core.autocrlf=false --config core.eol=lf " &
44
+ & " { submoduleFlag } { depthArg} { branchArg} { url} { downloadDir} " )
43
45
of DownloadMethod .hg:
44
46
let
45
47
tipArg = if onlyTip: " -r tip " else : " "
46
48
branchArg = if branch == " " : " " else : & " -b { branch} "
47
49
discard tryDoCmdEx (& " hg clone { tipArg} { branchArg} { url} { downloadDir} " )
48
50
49
- proc gitFetchTags * (repoDir: string , downloadMethod: DownloadMethod ) =
51
+ proc gitFetchTags * (repoDir: string , downloadMethod: DownloadMethod , options: Options ) =
50
52
case downloadMethod:
51
53
of DownloadMethod .git:
52
- tryDoCmdEx (& " git -C { repoDir} fetch --tags " )
54
+ let submoduleFlag = if not options.ignoreSubmodules: " --recurse-submodules" else : " "
55
+ tryDoCmdEx (& " git -C { repoDir} fetch --tags " & submoduleFlag)
53
56
of DownloadMethod .hg:
54
57
assert false , " hg not supported"
55
58
@@ -144,7 +147,7 @@ proc getUrlData*(url: string): (string, Table[string, string]) =
144
147
145
148
proc cloneSpecificRevision (downloadMethod: DownloadMethod ,
146
149
url, downloadDir: string ,
147
- vcsRevision: Sha1Hash ) =
150
+ vcsRevision: Sha1Hash , options: Options ) =
148
151
assert vcsRevision != notSetSha1Hash
149
152
150
153
display (" Cloning" , " revision: " & $ vcsRevision, priority = MediumPriority )
@@ -158,7 +161,8 @@ proc cloneSpecificRevision(downloadMethod: DownloadMethod,
158
161
discard tryDoCmdEx (
159
162
& " git -C { downloadDir} fetch --depth 1 origin { vcsRevision} " )
160
163
discard tryDoCmdEx (& " git -C { downloadDir} reset --hard FETCH_HEAD " )
161
- downloadDir.updateSubmodules
164
+ if not options.ignoreSubmodules:
165
+ downloadDir.updateSubmodules
162
166
of DownloadMethod .hg:
163
167
discard tryDoCmdEx (& " hg clone { url} -r { vcsRevision} " )
164
168
@@ -372,7 +376,7 @@ proc doDownload(url, downloadDir: string, verRange: VersionRange,
372
376
if downloadTarball (url, options):
373
377
discard doDownloadTarball (url, downloadDir, $ vcsRevision, false )
374
378
else :
375
- cloneSpecificRevision (downMethod, url, downloadDir, vcsRevision)
379
+ cloneSpecificRevision (downMethod, url, downloadDir, vcsRevision, options )
376
380
result .vcsRevision = vcsRevision
377
381
elif verRange.kind == verSpecial:
378
382
# We want a specific commit/branch/tag here.
@@ -382,7 +386,7 @@ proc doDownload(url, downloadDir: string, verRange: VersionRange,
382
386
result .vcsRevision = doDownloadTarball (url, downloadDir, " HEAD" , true )
383
387
else :
384
388
doClone (downMethod, url, downloadDir,
385
- onlyTip = not options.forceFullClone)
389
+ onlyTip = not options.forceFullClone, options = options )
386
390
else :
387
391
assert ($ verRange.spe)[0 ] == '#' ,
388
392
" The special version must start with '#'."
@@ -392,10 +396,10 @@ proc doDownload(url, downloadDir: string, verRange: VersionRange,
392
396
url, downloadDir, specialVersion, true )
393
397
else :
394
398
# Grab the full repo.
395
- doClone (downMethod, url, downloadDir, onlyTip = false )
399
+ doClone (downMethod, url, downloadDir, onlyTip = false , options = options )
396
400
# Then perform a checkout operation to get the specified branch/commit.
397
401
# `spe` starts with '#', trim it.
398
- doCheckout (downMethod, downloadDir, specialVersion)
402
+ doCheckout (downMethod, downloadDir, specialVersion, options = options )
399
403
result .version = verRange.spe
400
404
else :
401
405
case downMethod
@@ -415,26 +419,26 @@ proc doDownload(url, downloadDir: string, verRange: VersionRange,
415
419
display (" Cloning" , " latest tagged version: " & latest.tag,
416
420
priority = MediumPriority )
417
421
doClone (downMethod, url, downloadDir, latest.tag,
418
- onlyTip = not options.forceFullClone)
422
+ onlyTip = not options.forceFullClone, options = options )
419
423
else :
420
424
display (" Warning:" , " The package has no tagged releases, downloading HEAD instead." , Warning ,
421
425
priority = HighPriority )
422
426
if downloadTarball (url, options):
423
427
result .vcsRevision = doDownloadTarball (url, downloadDir, " HEAD" , true )
424
428
else :
425
429
# If no commits have been tagged on the repo we just clone HEAD.
426
- doClone (downMethod, url, downloadDir, onlyTip = not options.forceFullClone) # Grab HEAD.
430
+ doClone (downMethod, url, downloadDir, onlyTip = not options.forceFullClone, options = options ) # Grab HEAD.
427
431
of DownloadMethod .hg:
428
432
doClone (downMethod, url, downloadDir,
429
- onlyTip = not options.forceFullClone)
433
+ onlyTip = not options.forceFullClone, options = options )
430
434
result .version = getHeadName (downMethod)
431
435
let versions = getTagsList (downloadDir, downMethod).getVersionList ()
432
436
433
437
if versions.len > 0 :
434
438
getLatestByTag:
435
439
display (" Switching" , " to latest tagged version: " & latest.tag,
436
440
priority = MediumPriority )
437
- doCheckout (downMethod, downloadDir, latest.tag)
441
+ doCheckout (downMethod, downloadDir, latest.tag, options = options )
438
442
else :
439
443
display (" Warning:" , " The package has no tagged releases, downloading HEAD instead." , Warning ,
440
444
priority = HighPriority )
0 commit comments