Skip to content

Commit

Permalink
fix(terraform): Escape literal . in Bitbucket module ref regex (#26452)
Browse files Browse the repository at this point in the history
  • Loading branch information
JanGe committed Dec 29, 2023
1 parent f6cf9a4 commit 831fba0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
Expand Up @@ -148,6 +148,9 @@ describe('modules/manager/terraform/extractors/others/modules', () => {
const subfolderWithDoubleSlash = bitbucketRefMatchRegex.exec(
'bitbucket.org/hashicorp/example.git//terraform?ref=v1.0.0',
)?.groups;
const subfolderWithGitInName = bitbucketRefMatchRegex.exec(
'bitbucket.org/hashicorp/example.git//terraform-git?ref=v1.0.0',
)?.groups;
const depth = bitbucketRefMatchRegex.exec(
'git::https://git@bitbucket.org/hashicorp/example.git?depth=1&ref=v1.0.0',
)?.groups;
Expand Down Expand Up @@ -180,6 +183,11 @@ describe('modules/manager/terraform/extractors/others/modules', () => {
project: 'example',
tag: 'v1.0.0',
});
expect(subfolderWithGitInName).toMatchObject({
workspace: 'hashicorp',
project: 'example',
tag: 'v1.0.0',
});
expect(depth).toMatchObject({
workspace: 'hashicorp',
project: 'example',
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/terraform/extractors/others/modules.ts
Expand Up @@ -13,7 +13,7 @@ export const githubRefMatchRegex = regEx(
/github\.com([/:])(?<project>[^/]+\/[a-z0-9-_.]+).*\?(depth=\d+&)?ref=(?<tag>.*?)(&depth=\d+)?$/i,
);
export const bitbucketRefMatchRegex = regEx(
/(?:git::)?(?<url>(?:http|https|ssh)?(?::\/\/)?(?:.*@)?(?<path>bitbucket\.org\/(?<workspace>.*)\/(?<project>.*).git\/?(?<subfolder>.*)))\?(depth=\d+&)?ref=(?<tag>.*?)(&depth=\d+)?$/,
/(?:git::)?(?<url>(?:http|https|ssh)?(?::\/\/)?(?:.*@)?(?<path>bitbucket\.org\/(?<workspace>.*)\/(?<project>.*)\.git\/?(?<subfolder>.*)))\?(depth=\d+&)?ref=(?<tag>.*?)(&depth=\d+)?$/,
);
export const gitTagsRefMatchRegex = regEx(
/(?:git::)?(?<url>(?:(?:http|https|ssh):\/\/)?(?:.*@)?(?<path>.*\/(?<project>.*\/.*)))\?(depth=\d+&)?ref=(?<tag>.*?)(&depth=\d+)?$/,
Expand Down

0 comments on commit 831fba0

Please sign in to comment.