From 9788a0a0e307247d3edb189ea0e884b03d9eb97f Mon Sep 17 00:00:00 2001 From: Jamie Magee <JamieMagee@users.noreply.github.com> Date: Wed, 4 Nov 2020 15:39:21 +0100 Subject: [PATCH] feat(git-submodules): add cloneSubmodules configuration option (#7644) --- docs/usage/configuration-options.md | 2 ++ lib/config/definitions.ts | 7 +++++++ lib/util/git/index.spec.ts | 2 ++ lib/util/git/index.ts | 17 ++++++++++------- 4 files changed, 21 insertions(+), 7 deletions(-) diff --git a/docs/usage/configuration-options.md b/docs/usage/configuration-options.md index 7661e6cc53..f11c8f540a 100644 --- a/docs/usage/configuration-options.md +++ b/docs/usage/configuration-options.md @@ -214,6 +214,8 @@ You can also configure this field to `"mirror:x"` where `x` is the name of a pac Doing so means that the `package.json` `version` field will mirror whatever the version is that `x` depended on. Make sure that version is a pinned version of course, as otherwise it won't be valid. +## cloneSubmodules + ## commitBody Configure this if you wish Renovate to add a commit body, otherwise Renovate just uses a regular single-line commit. diff --git a/lib/config/definitions.ts b/lib/config/definitions.ts index 3d50d2369e..4b76f936e7 100644 --- a/lib/config/definitions.ts +++ b/lib/config/definitions.ts @@ -1844,6 +1844,13 @@ const options: RenovateOptions[] = [ cli: false, env: false, }, + { + name: 'cloneSubmodules', + description: + 'Set to false to disable initialization of submodules during repository clone', + type: 'boolean', + default: true, + }, ]; export function getOptions(): RenovateOptions[] { diff --git a/lib/util/git/index.spec.ts b/lib/util/git/index.spec.ts index 6a5311fc7d..65ff2307fd 100644 --- a/lib/util/git/index.spec.ts +++ b/lib/util/git/index.spec.ts @@ -101,6 +101,7 @@ describe('platform/git', () => { await repo.submoduleAdd(base.path, 'submodule'); await repo.commit('Add submodule'); await git.initRepo({ + cloneSubmodules: true, localDir: tmpDir.path, url: base.path, }); @@ -420,6 +421,7 @@ describe('platform/git', () => { ]); await repo.commit('Add submodule'); await git.initRepo({ + cloneSubmodules: true, localDir: tmpDir.path, url: base.path, }); diff --git a/lib/util/git/index.ts b/lib/util/git/index.ts index 925443be3b..7a26df73b5 100644 --- a/lib/util/git/index.ts +++ b/lib/util/git/index.ts @@ -39,6 +39,7 @@ interface StorageConfig { extraCloneOpts?: GitOptions; gitAuthorName?: string; gitAuthorEmail?: string; + cloneSubmodules?: boolean; } interface LocalConfig extends StorageConfig { @@ -263,13 +264,15 @@ export async function syncGit(): Promise<void> { logger.debug({ durationMs }, 'git clone completed'); } config.currentBranchSha = (await git.raw(['rev-parse', 'HEAD'])).trim(); - const submodules = await getSubmodules(); - for (const submodule of submodules) { - try { - logger.debug(`Cloning git submodule at ${submodule}`); - await git.submoduleUpdate(['--init', '--', submodule]); - } catch (err) { - logger.warn(`Unable to initialise git submodule at ${submodule}`); + if (config.cloneSubmodules) { + const submodules = await getSubmodules(); + for (const submodule of submodules) { + try { + logger.debug(`Cloning git submodule at ${submodule}`); + await git.submoduleUpdate(['--init', submodule]); + } catch (err) { + logger.warn(`Unable to initialise git submodule at ${submodule}`); + } } } try { -- GitLab