Skip to content

Commit

Permalink
fix(manager/terragrunt): use git-tags datasource for bitbucket-server (
Browse files Browse the repository at this point in the history
  • Loading branch information
Churro committed Jun 4, 2024
1 parent 760a646 commit 4039ace
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
5 changes: 5 additions & 0 deletions lib/modules/manager/terragrunt/__fixtures__/2.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,8 @@ terraform {
terraform {
source = "git::https://gitea.com/hashicorp/example?ref=v1.0.0"
}

# gittags fallback for bitbucket-server
terraform {
source = "git::https://bitbucket.example.com/hashicorp/example?ref=v1.0.0"
}
9 changes: 8 additions & 1 deletion lib/modules/manager/terragrunt/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -246,9 +246,16 @@ describe('modules/manager/terragrunt/extract', () => {
packageName: 'hashicorp/example',
registryUrls: ['https://gitea.com'],
},
{
currentValue: 'v1.0.0',
datasource: 'git-tags',
depName: 'bitbucket.example.com/hashicorp/example',
depType: 'gitTags',
packageName: 'https://bitbucket.example.com/hashicorp/example',
},
],
});
expect(res?.deps).toHaveLength(35);
expect(res?.deps).toHaveLength(36);
expect(res?.deps.filter((dep) => dep.skipReason)).toHaveLength(4);
});

Expand Down
1 change: 1 addition & 0 deletions lib/util/common.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('util/common', () => {
${'https://myorg.visualstudio.com/my-project/_git/my-repo.git'} | ${'azure'}
${'https://bitbucket.org/some-org/some-repo'} | ${'bitbucket'}
${'https://bitbucket.com/some-org/some-repo'} | ${'bitbucket'}
${'https://bitbucket.example.com/some-org/some-repo'} | ${'bitbucket-server'}
${'https://gitea.com/semantic-release/gitlab'} | ${'gitea'}
${'https://forgejo.example.com/semantic-release/gitlab'} | ${'gitea'}
${'https://github.com/semantic-release/gitlab'} | ${'github'}
Expand Down
14 changes: 12 additions & 2 deletions lib/util/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,24 @@ import { parseUrl } from './url';
*/
export function detectPlatform(
url: string,
): 'azure' | 'bitbucket' | 'gitea' | 'github' | 'gitlab' | null {
):
| 'azure'
| 'bitbucket'
| 'bitbucket-server'
| 'gitea'
| 'github'
| 'gitlab'
| null {
const { hostname } = parseUrl(url) ?? {};
if (hostname === 'dev.azure.com' || hostname?.endsWith('.visualstudio.com')) {
return 'azure';
}
if (hostname === 'bitbucket.org' || hostname?.includes('bitbucket')) {
if (hostname === 'bitbucket.org' || hostname === 'bitbucket.com') {
return 'bitbucket';
}
if (hostname?.includes('bitbucket')) {
return 'bitbucket-server';
}
if (
hostname &&
(['gitea.com', 'codeberg.org'].includes(hostname) ||
Expand Down

0 comments on commit 4039ace

Please sign in to comment.