diff --git a/lib/modules/manager/terragrunt/__fixtures__/2.hcl b/lib/modules/manager/terragrunt/__fixtures__/2.hcl index ac753da5b3a8ac..523dd78b898881 100644 --- a/lib/modules/manager/terragrunt/__fixtures__/2.hcl +++ b/lib/modules/manager/terragrunt/__fixtures__/2.hcl @@ -182,7 +182,7 @@ terraform { # gitlab-tags ssh with custom port terraform { - source = "git::ssh://gitlab.com:1234/hashicorp/example.git?ref=v1.0.2" + source = "git::ssh://gitlab.com:1234/hashicorp/example.git//foo/bar?ref=v1.0.2" } # gitea-tags diff --git a/lib/modules/manager/terragrunt/__fixtures__/3.hcl b/lib/modules/manager/terragrunt/__fixtures__/3.hcl index b33f8d4fedfc02..24e81c345cfc7b 100644 --- a/lib/modules/manager/terragrunt/__fixtures__/3.hcl +++ b/lib/modules/manager/terragrunt/__fixtures__/3.hcl @@ -182,7 +182,7 @@ terraform { # gitlab-tags ssh with custom port terraform { - source = "git::ssh://gitlab.com:1234/hashicorp/example.git?ref=v1.0.2" + source = "git::ssh://gitlab.com:1234/hashicorp/example.git//foo/bar?ref=v1.0.2" } # gitea-tags diff --git a/lib/modules/manager/terragrunt/__fixtures__/4.hcl b/lib/modules/manager/terragrunt/__fixtures__/4.hcl index 42a0a46e47944d..8ac54753fe0d21 100644 --- a/lib/modules/manager/terragrunt/__fixtures__/4.hcl +++ b/lib/modules/manager/terragrunt/__fixtures__/4.hcl @@ -183,7 +183,7 @@ terraform { # gitlab-tags ssh with custom port terraform { - source = "git::ssh://gitlab.com:1234/hashicorp/example.git?ref=v1.0.2" + source = "git::ssh://gitlab.com:1234/hashicorp/example.git//foo/bar?ref=v1.0.2" } # gitea-tags diff --git a/lib/modules/manager/terragrunt/modules.ts b/lib/modules/manager/terragrunt/modules.ts index 665966c0295689..9d71e1e8aa6483 100644 --- a/lib/modules/manager/terragrunt/modules.ts +++ b/lib/modules/manager/terragrunt/modules.ts @@ -75,8 +75,12 @@ export function analyseTerragruntModule( logger.debug('Terragrunt module contains subdirectory'); } dep.depType = 'gitTags'; - // We don't want to have .git or subdirectory in the depName - dep.depName = `${hostname}${pathname.split('//')[0].replace(regEx('.git$'), '')}`; + // We don't want to have leading slash, .git or subdirectory in the repository path + const repositoryPath = pathname + .replace(regEx(/^\//), '') + .split('//')[0] + .replace(regEx('.git$'), ''); + dep.depName = `${hostname}/${repositoryPath}`; dep.currentValue = tag; dep.datasource = detectGitTagDatasource(url); if (dep.datasource === GitTagsDatasource.id) { @@ -87,10 +91,7 @@ export function analyseTerragruntModule( } } else { // The packageName should only contain the path to the repository - dep.packageName = pathname - .replace(regEx(/^\//), '') - .replace(regEx('.git$'), '') - .split('//')[0]; + dep.packageName = repositoryPath; dep.registryUrls = [ protocol === 'https:' ? `https://${host}` : `https://${hostname}`, ];