diff --git a/lib/manager/terraform/__fixtures__/1.tf b/lib/manager/terraform/__fixtures__/1.tf index 9ee1515d28aadb4e13569fda450de3f08d8fd2ec..835c564b38fd4ddc8c1f4a42be52fb7fc520415d 100644 --- a/lib/manager/terraform/__fixtures__/1.tf +++ b/lib/manager/terraform/__fixtures__/1.tf @@ -6,6 +6,14 @@ module "bar" { source = "github.com/hashicorp/example?ref=next" } +module "repo-with-dot" { + source = "github.com/hashicorp/example.2.3?ref=v1.0.0" +} + +module "repo-with-dot-and-git-suffix" { + source = "github.com/hashicorp/example.2.3.git?ref=v1.0.0" +} + module "consul" { source = "hashicorp/consul/aws" version = "0.1.0" diff --git a/lib/manager/terraform/__snapshots__/extract.spec.ts.snap b/lib/manager/terraform/__snapshots__/extract.spec.ts.snap index d1cdedfa3154bba8794aecbe97c020ec73c0a300..3fb1bb25974f48b5359e859ed0eed8d1989869e6 100644 --- a/lib/manager/terraform/__snapshots__/extract.spec.ts.snap +++ b/lib/manager/terraform/__snapshots__/extract.spec.ts.snap @@ -20,6 +20,22 @@ Object { "lookupName": "hashicorp/example", "skipReason": "unsupported-version", }, + Object { + "currentValue": "v1.0.0", + "datasource": "github-tags", + "depName": "github.com/hashicorp/example.2.3", + "depNameShort": "hashicorp/example.2.3", + "depType": "github", + "lookupName": "hashicorp/example.2.3", + }, + Object { + "currentValue": "v1.0.0", + "datasource": "github-tags", + "depName": "github.com/hashicorp/example.2.3", + "depNameShort": "hashicorp/example.2.3", + "depType": "github", + "lookupName": "hashicorp/example.2.3", + }, Object { "currentValue": "0.1.0", "datasource": "terraform-module", diff --git a/lib/manager/terraform/extract.spec.ts b/lib/manager/terraform/extract.spec.ts index 5926e15182f8369973e3af089587da86582ba67c..c0417b956471a295baf43403bfc4dfcb6c1b0ba2 100644 --- a/lib/manager/terraform/extract.spec.ts +++ b/lib/manager/terraform/extract.spec.ts @@ -19,7 +19,7 @@ describe('lib/manager/terraform/extract', () => { it('extracts', () => { const res = extractPackageFile(tf1); expect(res).toMatchSnapshot(); - expect(res.deps).toHaveLength(22); + expect(res.deps).toHaveLength(24); expect(res.deps.filter((dep) => dep.skipReason)).toHaveLength(6); }); it('returns null if only local deps', () => { diff --git a/lib/manager/terraform/extract.ts b/lib/manager/terraform/extract.ts index d1e303a60724991609a970c8cd77cde2ab5a778f..507697cc62dc13dfae2c3d7bfdde58886e92b5bf 100644 --- a/lib/manager/terraform/extract.ts +++ b/lib/manager/terraform/extract.ts @@ -85,7 +85,7 @@ export function extractPackageFile(content: string): PackageFile | null { dep.managerData.terraformDependencyType === TerraformDependencyTypes.module ) { - const githubRefMatch = /github.com(\/|:)([^/]+\/[a-z0-9-]+).*\?ref=(.*)$/.exec( + const githubRefMatch = /github.com(\/|:)([^/]+\/[a-z0-9-.]+).*\?ref=(.*)$/.exec( dep.managerData.source ); // Regex would need to be updated to support ssh:// @@ -94,12 +94,13 @@ export function extractPackageFile(content: string): PackageFile | null { ); /* eslint-disable no-param-reassign */ if (githubRefMatch) { + const depNameShort = githubRefMatch[2].replace(/\.git$/, ''); dep.depType = 'github'; - dep.depName = 'github.com/' + githubRefMatch[2]; - dep.depNameShort = githubRefMatch[2]; + dep.depName = 'github.com/' + depNameShort; + dep.depNameShort = depNameShort; dep.currentValue = githubRefMatch[3]; dep.datasource = datasourceGithubTags.id; - dep.lookupName = githubRefMatch[2]; + dep.lookupName = depNameShort; dep.managerData.lineNumber = dep.managerData.sourceLine; if (!isVersion(dep.currentValue)) { dep.skipReason = SkipReason.UnsupportedVersion;