Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(bitbucket): use correct case #21002

Merged
merged 6 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions docs/usage/faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ If you're self hosting Renovate, use the latest release if possible.

| Feature | Platforms which lack feature | See Renovate issue(s) |
| -------------------- | ---------------------------------------------------------- | ------------------------------------------------------------ |
| Dependency Dashboard | Azure, BitBucket, BitBucket Server | [#9592](https://github.com/renovatebot/renovate/issues/9592) |
| Hosted app | Azure, BitBucket, BitBucket Server, Forgejo, Gitea, GitLab | |
| Dependency Dashboard | Azure, Bitbucket, Bitbucket Server | [#9592](https://github.com/renovatebot/renovate/issues/9592) |
| Hosted app | Azure, Bitbucket, Bitbucket Server, Forgejo, Gitea, GitLab | |

## Major platform features not supported by Renovate

Expand Down
4 changes: 2 additions & 2 deletions lib/constants/platform.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BitBucketTagsDatasource } from '../modules/datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../modules/datasource/bitbucket-tags';
import { GithubReleasesDatasource } from '../modules/datasource/github-releases';
import { GithubTagsDatasource } from '../modules/datasource/github-tags';
import { GitlabPackagesDatasource } from '../modules/datasource/gitlab-packages';
Expand Down Expand Up @@ -58,7 +58,7 @@ describe('constants/platform', () => {

it('should be part of the BITBUCKET_API_USING_HOST_TYPES ', () => {
expect(
BITBUCKET_API_USING_HOST_TYPES.includes(BitBucketTagsDatasource.id)
BITBUCKET_API_USING_HOST_TYPES.includes(BitbucketTagsDatasource.id)
).toBeTrue();
expect(BITBUCKET_API_USING_HOST_TYPES.includes('bitbucket')).toBeTrue();
});
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AwsMachineImageDataSource } from './aws-machine-image';
import { AwsRdsDataSource } from './aws-rds';
import { AzureBicepResourceDatasource } from './azure-bicep-resource';
import { AzurePipelinesTasksDatasource } from './azure-pipelines-tasks';
import { BitBucketTagsDatasource } from './bitbucket-tags';
import { BitbucketTagsDatasource } from './bitbucket-tags';
import { CdnJsDatasource } from './cdnjs';
import { ClojureDatasource } from './clojure';
import { ConanDatasource } from './conan';
Expand Down Expand Up @@ -62,7 +62,7 @@ api.set(AwsMachineImageDataSource.id, new AwsMachineImageDataSource());
api.set(AwsRdsDataSource.id, new AwsRdsDataSource());
api.set(AzureBicepResourceDatasource.id, new AzureBicepResourceDatasource());
api.set(AzurePipelinesTasksDatasource.id, new AzurePipelinesTasksDatasource());
api.set(BitBucketTagsDatasource.id, new BitBucketTagsDatasource());
api.set(BitbucketTagsDatasource.id, new BitbucketTagsDatasource());
api.set(CdnJsDatasource.id, new CdnJsDatasource());
api.set(ClojureDatasource.id, new ClojureDatasource());
api.set(ConanDatasource.id, new ConanDatasource());
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/bitbucket-tags/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { getDigest, getPkgReleases } from '..';
import * as httpMock from '../../../../test/http-mock';
import { BitBucketTagsDatasource } from '.';
import { BitbucketTagsDatasource } from '.';

const datasource = BitBucketTagsDatasource.id;
const datasource = BitbucketTagsDatasource.id;

describe('modules/datasource/bitbucket-tags/index', () => {
describe('getReleases', () => {
Expand Down
32 changes: 16 additions & 16 deletions lib/modules/datasource/bitbucket-tags/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import { Datasource } from '../datasource';
import type { DigestConfig, GetReleasesConfig, ReleaseResult } from '../types';
import type { BitbucketCommit, BitbucketTag } from './types';

export class BitBucketTagsDatasource extends Datasource {
bitbucketHttp = new BitbucketHttp(BitBucketTagsDatasource.id);
export class BitbucketTagsDatasource extends Datasource {
bitbucketHttp = new BitbucketHttp(BitbucketTagsDatasource.id);

static readonly id = 'bitbucket-tags';

Expand All @@ -18,10 +18,10 @@ export class BitBucketTagsDatasource extends Datasource {

static readonly defaultRegistryUrls = ['https://bitbucket.org'];

static readonly cacheNamespace = `datasource-${BitBucketTagsDatasource.id}`;
static readonly cacheNamespace = `datasource-${BitbucketTagsDatasource.id}`;

constructor() {
super(BitBucketTagsDatasource.id);
super(BitbucketTagsDatasource.id);
}

static getRegistryURL(registryUrl?: string): string {
Expand All @@ -34,22 +34,22 @@ export class BitBucketTagsDatasource extends Datasource {
repo: string,
type: string
): string {
return `${BitBucketTagsDatasource.getRegistryURL(
return `${BitbucketTagsDatasource.getRegistryURL(
registryUrl
)}:${repo}:${type}`;
}

static getSourceUrl(packageName: string, registryUrl?: string): string {
const url = BitBucketTagsDatasource.getRegistryURL(registryUrl);
const url = BitbucketTagsDatasource.getRegistryURL(registryUrl);
const normalizedUrl = ensureTrailingSlash(url);
return `${normalizedUrl}${packageName}`;
}

// getReleases fetches list of tags for the repository
@cache({
namespace: BitBucketTagsDatasource.cacheNamespace,
namespace: BitbucketTagsDatasource.cacheNamespace,
key: ({ registryUrl, packageName }: GetReleasesConfig) =>
BitBucketTagsDatasource.getCacheKey(registryUrl, packageName, 'tags'),
BitbucketTagsDatasource.getCacheKey(registryUrl, packageName, 'tags'),
})
async getReleases({
registryUrl,
Expand All @@ -59,8 +59,8 @@ export class BitBucketTagsDatasource extends Datasource {
const bitbucketTags = await utils.accumulateValues(url);

const dependency: ReleaseResult = {
sourceUrl: BitBucketTagsDatasource.getSourceUrl(repo, registryUrl),
registryUrl: BitBucketTagsDatasource.getRegistryURL(registryUrl),
sourceUrl: BitbucketTagsDatasource.getSourceUrl(repo, registryUrl),
registryUrl: BitbucketTagsDatasource.getRegistryURL(registryUrl),
releases: bitbucketTags.map(({ name, target }) => ({
version: name,
gitRef: name,
Expand All @@ -73,9 +73,9 @@ export class BitBucketTagsDatasource extends Datasource {

// getTagCommit fetched the commit has for specified tag
@cache({
namespace: BitBucketTagsDatasource.cacheNamespace,
namespace: BitbucketTagsDatasource.cacheNamespace,
key: (registryUrl: string | undefined, repo: string, tag: string): string =>
BitBucketTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`),
BitbucketTagsDatasource.getCacheKey(registryUrl, repo, `tag-${tag}`),
})
async getTagCommit(
_registryUrl: string | undefined,
Expand All @@ -91,9 +91,9 @@ export class BitBucketTagsDatasource extends Datasource {
}

@cache({
namespace: BitBucketTagsDatasource.cacheNamespace,
namespace: BitbucketTagsDatasource.cacheNamespace,
key: (registryUrl: string, repo: string) =>
BitBucketTagsDatasource.getCacheKey(registryUrl, repo, 'mainbranch'),
BitbucketTagsDatasource.getCacheKey(registryUrl, repo, 'mainbranch'),
ttlMinutes: 60,
})
async getMainBranch(repo: string): Promise<string> {
Expand All @@ -107,9 +107,9 @@ export class BitBucketTagsDatasource extends Datasource {
// getDigest fetched the latest commit for repository main branch
// however, if newValue is provided, then getTagCommit is called
@cache({
namespace: BitBucketTagsDatasource.cacheNamespace,
namespace: BitbucketTagsDatasource.cacheNamespace,
key: ({ registryUrl, packageName }: DigestConfig) =>
BitBucketTagsDatasource.getCacheKey(registryUrl, packageName, 'digest'),
BitbucketTagsDatasource.getCacheKey(registryUrl, packageName, 'digest'),
})
override async getDigest(
{ packageName: repo, registryUrl }: DigestConfig,
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/go/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import * as hostRules from '../../../util/host-rules';
import { Http } from '../../../util/http';
import { regEx } from '../../../util/regex';
import { trimLeadingSlash, trimTrailingSlash } from '../../../util/url';
import { BitBucketTagsDatasource } from '../bitbucket-tags';
import { BitbucketTagsDatasource } from '../bitbucket-tags';
import { GitTagsDatasource } from '../git-tags';
import { GithubTagsDatasource } from '../github-tags';
import { GitlabTagsDatasource } from '../gitlab-tags';
Expand Down Expand Up @@ -53,7 +53,7 @@ export class BaseGoDatasource {
const split = goModule.split('/');
const packageName = split[1] + '/' + split[2];
return {
datasource: BitBucketTagsDatasource.id,
datasource: BitbucketTagsDatasource.id,
packageName,
registryUrl: 'https://bitbucket.org',
};
Expand Down
6 changes: 3 additions & 3 deletions lib/modules/datasource/go/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { getSourceUrl as githubSourceUrl } from '../../../util/github/url';
import { BitBucketTagsDatasource } from '../bitbucket-tags';
import { BitbucketTagsDatasource } from '../bitbucket-tags';
import { GithubTagsDatasource } from '../github-tags';
import { GitlabTagsDatasource } from '../gitlab-tags';
import { getSourceUrl as gitlabSourceUrl } from '../gitlab-tags/util';
Expand All @@ -24,8 +24,8 @@ export function getSourceUrl(
return gitlabSourceUrl(packageName, registryUrl);
}

if (datasource === BitBucketTagsDatasource.id) {
return BitBucketTagsDatasource.getSourceUrl(packageName, registryUrl);
if (datasource === BitbucketTagsDatasource.id) {
return BitbucketTagsDatasource.getSourceUrl(packageName, registryUrl);
}
}

Expand Down
4 changes: 2 additions & 2 deletions lib/modules/datasource/go/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { cache } from '../../../util/cache/package/decorator';
import { regEx } from '../../../util/regex';
import { addSecretForSanitizing } from '../../../util/sanitize';
import { parseUrl } from '../../../util/url';
import { BitBucketTagsDatasource } from '../bitbucket-tags';
import { BitbucketTagsDatasource } from '../bitbucket-tags';
import { Datasource } from '../datasource';
import { GitTagsDatasource } from '../git-tags';
import { GithubTagsDatasource } from '../github-tags';
Expand Down Expand Up @@ -76,7 +76,7 @@ export class GoDatasource extends Datasource {
case GithubTagsDatasource.id: {
return this.direct.github.getDigest(source, tag);
}
case BitBucketTagsDatasource.id: {
case BitbucketTagsDatasource.id: {
return this.direct.bitbucket.getDigest?.(source, tag) ?? null;
}
case GitlabTagsDatasource.id: {
Expand Down
8 changes: 4 additions & 4 deletions lib/modules/datasource/go/releases-direct.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { logger } from '../../../logger';
import { cache } from '../../../util/cache/package/decorator';
import { regEx } from '../../../util/regex';
import { BitBucketTagsDatasource } from '../bitbucket-tags';
import { BitbucketTagsDatasource } from '../bitbucket-tags';
import { Datasource } from '../datasource';
import { GitTagsDatasource } from '../git-tags';
import { GithubTagsDatasource } from '../github-tags';
Expand All @@ -16,14 +16,14 @@ export class GoDirectDatasource extends Datasource {
git: GitTagsDatasource;
github: GithubTagsDatasource;
gitlab: GitlabTagsDatasource;
bitbucket: BitBucketTagsDatasource;
bitbucket: BitbucketTagsDatasource;

constructor() {
super(GoDirectDatasource.id);
this.git = new GitTagsDatasource();
this.github = new GithubTagsDatasource();
this.gitlab = new GitlabTagsDatasource();
this.bitbucket = new BitBucketTagsDatasource();
this.bitbucket = new BitbucketTagsDatasource();
}

/**
Expand Down Expand Up @@ -70,7 +70,7 @@ export class GoDirectDatasource extends Datasource {
res = await this.gitlab.getReleases(source);
break;
}
case BitBucketTagsDatasource.id: {
case BitbucketTagsDatasource.id: {
res = await this.bitbucket.getReleases(source);
break;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/bitbucket-pipelines/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { logger } from '../../../logger';
import { newlineRegex, regEx } from '../../../util/regex';
import { BitBucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { getDep } from '../dockerfile/extract';
import type { PackageDependency, PackageFileContent } from '../types';

Expand Down Expand Up @@ -47,7 +47,7 @@ function addDepAsBitbucketTag(
const dep: PackageDependency = {
depName,
currentValue,
datasource: BitBucketTagsDatasource.id,
datasource: BitbucketTagsDatasource.id,
};
dep.depType = 'bitbucket-tags';
deps.push(dep);
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/deps-edn/extract.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import is from '@sindresorhus/is';
import { regEx } from '../../../util/regex';
import { BitBucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { ClojureDatasource } from '../../datasource/clojure';
import { CLOJARS_REPO } from '../../datasource/clojure/common';
import { GitRefsDatasource } from '../../datasource/git-refs';
Expand Down Expand Up @@ -66,7 +66,7 @@ function resolveGitPackageFromEdnKey(

const bitbucketDependencyGroups = bitbucketDependencyRegex.exec(key)?.groups;
if (bitbucketDependencyGroups?.packageName) {
dep.datasource = BitBucketTagsDatasource.id;
dep.datasource = BitbucketTagsDatasource.id;
dep.packageName = bitbucketDependencyGroups.packageName;
return;
}
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/flux/extract.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { codeBlock } from 'common-tags';
import { Fixtures } from '../../../../test/fixtures';
import { GlobalConfig } from '../../../config/global';
import type { RepoGlobalConfig } from '../../../config/types';
import { BitBucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { DockerDatasource } from '../../datasource/docker';
import { GitRefsDatasource } from '../../datasource/git-refs';
import { GitTagsDatasource } from '../../datasource/git-tags';
Expand Down Expand Up @@ -455,7 +455,7 @@ describe('modules/manager/flux/extract', () => {
deps: [
{
currentValue: '2020.5.6+staging.ze',
datasource: BitBucketTagsDatasource.id,
datasource: BitbucketTagsDatasource.id,
depName: 'renovate-repo',
packageName: 'renovatebot/renovate',
sourceUrl: 'https://bitbucket.org/renovatebot/renovate',
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/flux/extract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { loadAll } from 'js-yaml';
import { logger } from '../../../logger';
import { readLocalFile } from '../../../util/fs';
import { regEx } from '../../../util/regex';
import { BitBucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { GitRefsDatasource } from '../../datasource/git-refs';
import { GitTagsDatasource } from '../../datasource/git-tags';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
Expand Down Expand Up @@ -130,7 +130,7 @@ function resolveGitRepositoryPerSourceTag(

const bitbucketMatchGroups = bitbucketUrlRegex.exec(gitUrl)?.groups;
if (bitbucketMatchGroups) {
dep.datasource = BitBucketTagsDatasource.id;
dep.datasource = BitbucketTagsDatasource.id;
dep.packageName = bitbucketMatchGroups.packageName;
dep.sourceUrl = `https://bitbucket.org/${dep.packageName}`;
return;
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/flux/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BitBucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { DockerDatasource } from '../../datasource/docker';
import { GitRefsDatasource } from '../../datasource/git-refs';
import { GitTagsDatasource } from '../../datasource/git-tags';
Expand All @@ -21,7 +21,7 @@ export const supportedDatasources = [
GithubTagsDatasource.id,
GitlabTagsDatasource.id,
GitTagsDatasource.id,
BitBucketTagsDatasource.id,
BitbucketTagsDatasource.id,
HelmDatasource.id,
DockerDatasource.id,
];
4 changes: 2 additions & 2 deletions lib/modules/manager/terraform/extractors/others/modules.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import is from '@sindresorhus/is';
import { logger } from '../../../../../logger';
import { regEx } from '../../../../../util/regex';
import { BitBucketTagsDatasource } from '../../../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../../../datasource/bitbucket-tags';
import { GitTagsDatasource } from '../../../../datasource/git-tags';
import { GithubTagsDatasource } from '../../../../datasource/github-tags';
import { TerraformModuleDatasource } from '../../../../datasource/terraform-module';
Expand Down Expand Up @@ -78,7 +78,7 @@ export class ModuleExtractor extends DependencyExtractor {
bitbucketRefMatch.groups.project;
dep.packageName = dep.depName;
dep.currentValue = bitbucketRefMatch.groups.tag;
dep.datasource = BitBucketTagsDatasource.id;
dep.datasource = BitbucketTagsDatasource.id;
} else if (azureDevOpsSshRefMatch?.groups) {
dep.depType = 'module';
dep.depName = `${azureDevOpsSshRefMatch.groups.organization}/${azureDevOpsSshRefMatch.groups.project}/${azureDevOpsSshRefMatch.groups.repository}${azureDevOpsSshRefMatch.groups.modulepath}`;
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/manager/terraform/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { BitBucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { BitbucketTagsDatasource } from '../../datasource/bitbucket-tags';
import { DockerDatasource } from '../../datasource/docker';
import { GitTagsDatasource } from '../../datasource/git-tags';
import { GithubReleasesDatasource } from '../../datasource/github-releases';
Expand All @@ -12,7 +12,7 @@ export { updateLockedDependency } from './lockfile/update-locked';
export { extractPackageFile } from './extract';

export const supportedDatasources = [
BitBucketTagsDatasource.id,
BitbucketTagsDatasource.id,
DockerDatasource.id,
GitTagsDatasource.id,
GithubTagsDatasource.id,
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/bitbucket-server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ export async function getJsonFile(
return JSON5.parse(raw);
}

// Initialize BitBucket Server by getting base branch
// Initialize Bitbucket Server by getting base branch
export async function initRepo({
repository,
cloneSubmodules,
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/bitbucket/comments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface Comment {

export type CommentsConfig = Pick<Config, 'repository'>;

interface EnsureBitBucketCommentConfig extends EnsureCommentConfig {
interface EnsureBitbucketCommentConfig extends EnsureCommentConfig {
config: CommentsConfig;
}

Expand Down Expand Up @@ -71,7 +71,7 @@ export async function ensureComment({
number: prNo,
topic,
content,
}: EnsureBitBucketCommentConfig): Promise<boolean> {
}: EnsureBitbucketCommentConfig): Promise<boolean> {
try {
const comments = await getComments(config, prNo);
let body: string;
Expand Down
2 changes: 1 addition & 1 deletion lib/modules/platform/bitbucket/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ Remember to:
## Unsupported platform features/concepts

- Adding assignees to PRs not supported (does not seem to be a Bitbucket concept)
- `automergeStrategy=rebase` not supported by BitBucket Cloud, see [Jira issue BCLOUD-16610](https://jira.atlassian.com/browse/BCLOUD-16610)
- `automergeStrategy=rebase` not supported by Bitbucket Cloud, see [Jira issue BCLOUD-16610](https://jira.atlassian.com/browse/BCLOUD-16610)