Skip to content

Commit 90031fc

Browse files
committed
refactor(vcs): Use common updateArgs
Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
1 parent 196a1f4 commit 90031fc

File tree

1 file changed

+4
-7
lines changed
  • plugins/version-control-systems/git/src/main/kotlin

1 file changed

+4
-7
lines changed

plugins/version-control-systems/git/src/main/kotlin/Git.kt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -315,18 +315,16 @@ class Git(
315315
private fun updateSubmodules(workingTree: GitWorkingTree) {
316316
if (!workingTree.getRootPath().resolve(".gitmodules").isFile) return
317317

318-
val recursive = "--recursive".takeIf { config.updateNestedSubmodules }
319-
320318
val insteadOf = REPOSITORY_URL_PREFIX_REPLACEMENTS.map { (prefix, replacement) ->
321319
"url.$replacement.insteadOf $prefix"
322320
}
323321

322+
val recursive = "--recursive".takeIf { config.updateNestedSubmodules }
323+
val updateArgs = listOfNotNull("submodule", "update", "--init", recursive)
324+
324325
runCatching {
325326
// TODO: Migrate this to JGit once https://bugs.eclipse.org/bugs/show_bug.cgi?id=580731 is implemented.
326-
val updateArgs = listOfNotNull(
327-
"submodule", "update", "--init", recursive, "--depth", "${config.historyDepth}"
328-
)
329-
workingTree.runGit(*updateArgs.toTypedArray())
327+
workingTree.runGit(*updateArgs.toTypedArray(), "--depth", "${config.historyDepth}")
330328

331329
insteadOf.forEach {
332330
val foreachArgs = listOfNotNull(
@@ -336,7 +334,6 @@ class Git(
336334
}
337335
}.recover {
338336
// As Git's dumb HTTP transport does not support shallow capabilities, also try to not limit the depth.
339-
val updateArgs = listOfNotNull("submodule", "update", "--init", recursive)
340337
workingTree.runGit(*updateArgs.toTypedArray())
341338
}
342339
}

0 commit comments

Comments
 (0)