Skip to content

Commit

Permalink
fix(terragrunt): remove .git from package name (#28726)
Browse files Browse the repository at this point in the history
  • Loading branch information
lstoeferle authored Apr 29, 2024
1 parent 5c60b6a commit e185788
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/modules/manager/terragrunt/__fixtures__/2.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ terraform {

# gitlab-tags ssh with custom port
terraform {
source = "git::ssh://gitlab.com:1234/hashicorp/example?ref=v1.0.2"
source = "git::ssh://gitlab.com:1234/hashicorp/example.git?ref=v1.0.2"
}

# gitea-tags
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/terragrunt/__fixtures__/3.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ terraform {

# gitlab-tags ssh with custom port
terraform {
source = "git::ssh://gitlab.com:1234/hashicorp/example?ref=v1.0.2"
source = "git::ssh://gitlab.com:1234/hashicorp/example.git?ref=v1.0.2"
}

# gitea-tags
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/terragrunt/__fixtures__/4.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ terraform {

# gitlab-tags ssh with custom port
terraform {
source = "git::ssh://gitlab.com:1234/hashicorp/example?ref=v1.0.2"
source = "git::ssh://gitlab.com:1234/hashicorp/example.git?ref=v1.0.2"
}

# gitea-tags
Expand Down
7 changes: 5 additions & 2 deletions lib/modules/manager/terragrunt/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export function analyseTerragruntModule(
}
dep.depType = 'gitTags';
// We don't want to have .git or subdirectory in the depName
dep.depName = `${hostname}${pathname.split('//')[0].replace('.git', '')}`;
dep.depName = `${hostname}${pathname.split('//')[0].replace(regEx('.git$'), '')}`;
dep.currentValue = tag;
dep.datasource = detectGitTagDatasource(url);
if (dep.datasource === GitTagsDatasource.id) {
Expand All @@ -87,7 +87,10 @@ export function analyseTerragruntModule(
}
} else {
// The packageName should only contain the path to the repository
dep.packageName = pathname.replace(/^\//, '').split('//')[0];
dep.packageName = pathname
.replace(regEx(/^\//), '')
.replace(regEx('.git$'), '')
.split('//')[0];
dep.registryUrls = [
protocol === 'https:' ? `https://${host}` : `https://${hostname}`,
];
Expand Down

0 comments on commit e185788

Please sign in to comment.