Skip to content

Commit

Permalink
Merge branch 'main' into feat/gitea-pr-cache
Browse files Browse the repository at this point in the history
  • Loading branch information
zharinov committed Jan 10, 2024
2 parents 05b0355 + 6954048 commit 4a0faf1
Show file tree
Hide file tree
Showing 10 changed files with 82 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
FROM ghcr.io/containerbase/devcontainer:9.31.3
FROM ghcr.io/containerbase/devcontainer:9.31.4
2 changes: 1 addition & 1 deletion docs/usage/.pages
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ nav:
- ... | getting-started
- Troubleshooting: 'troubleshooting.md'
- Configuration:
- 'Self-hosted': 'self-hosted-configuration.md'
- 'Repository': 'configuration-options.md'
- 'Self-hosted': 'self-hosted-configuration.md'
- 'Presets': 'config-presets.md'
- 'Validation': 'config-validation.md'
- ... | key-concepts
Expand Down
6 changes: 5 additions & 1 deletion docs/usage/self-hosted-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ description: Self-Hosted configuration usable in config file, CLI or environment

# Self-Hosted configuration options

You can only use these configuration options when you're self-hosting Renovate.
Only use these configuration options when you _self-host_ Renovate.

Do _not_ put the self-hosted config options listed on this page in your "repository config" file (`renovate.json` for example), because Renovate will ignore those config options, and may also create a config error issue.

The config options below _must_ be configured in the bot/admin config, so in either a environment variable, CLI option, or a special file like `config.js`.

Please also see [Self-Hosted Experimental Options](./self-hosted-experimental.md).

Expand Down
5 changes: 4 additions & 1 deletion lib/config/presets/internal/regex-managers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ export const presets: Record<string, Preset> = {
customManagers: [
{
customType: 'regex',
fileMatch: ['^.github/(?:workflows|actions)/.+\\.ya?ml$'],
fileMatch: [
'(^|/)(workflow-templates|\\.(?:github|gitea|forgejo)/(?:workflows|actions))/.+\\.ya?ml$',
'(^|/)action\\.ya?ml$',
],
matchStrings: [
'# renovate: datasource=(?<datasource>[a-z-.]+?) depName=(?<depName>[^\\s]+?)(?: (?:lookupName|packageName)=(?<packageName>[^\\s]+?))?(?: versioning=(?<versioning>[^\\s]+?))?(?: extractVersion=(?<extractVersion>[^\\s]+?))?\\s+[A-Za-z0-9_]+?_VERSION\\s*:\\s*["\']?(?<currentValue>.+?)["\']?\\s',
],
Expand Down
42 changes: 42 additions & 0 deletions lib/modules/datasource/go/base.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { mockDeep } from 'jest-mock-extended';
import { Fixtures } from '../../../../test/fixtures';
import * as httpMock from '../../../../test/http-mock';
import { mocked } from '../../../../test/util';
import { GlobalConfig } from '../../../config/global';
import * as _hostRules from '../../../util/host-rules';
import { GitTagsDatasource } from '../git-tags';
import { GithubTagsDatasource } from '../github-tags';
Expand Down Expand Up @@ -34,6 +35,7 @@ describe('modules/datasource/go/base', () => {
beforeEach(() => {
hostRules.find.mockReturnValue({});
hostRules.hosts.mockReturnValue([]);
GlobalConfig.reset();
});

describe('meta name=go-source', () => {
Expand Down Expand Up @@ -394,6 +396,46 @@ describe('modules/datasource/go/base', () => {

expect(res).toBeNull();
});

it('it correctly splits a URL where the endpoint is contained', async () => {
hostRules.hostType.mockReturnValue('gitlab');

GlobalConfig.set({ endpoint: 'https://example.com/gitlab/api/v4/' });

const meta =
'<meta name="go-import" content="example.com/gitlab/my-project/my-repo.git git https://example.com/gitlab/my-project/my-repo" />';
httpMock
.scope('https://example.com')
.get('/gitlab/my-project/my-repo.git?go-get=1')
.reply(200, meta);

const res = await BaseGoDatasource.getDatasource(
'example.com/gitlab/my-project/my-repo.git',
);

expect(res).toEqual({
datasource: GitlabTagsDatasource.id,
packageName: 'my-project/my-repo',
registryUrl: 'https://example.com/gitlab/',
});

GlobalConfig.set({ endpoint: 'https://example.com/gitlab/' });

httpMock
.scope('https://example.com')
.get('/gitlab/my-project/my-repo.git?go-get=1')
.reply(200, meta);

const res2 = await BaseGoDatasource.getDatasource(
'example.com/gitlab/my-project/my-repo.git',
);

expect(res2).toEqual({
datasource: GitlabTagsDatasource.id,
packageName: 'my-project/my-repo',
registryUrl: 'https://example.com/gitlab/',
});
});
});
});
});
27 changes: 24 additions & 3 deletions lib/modules/datasource/go/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// TODO: types (#22198)
import URL from 'node:url';
import { GlobalConfig } from '../../../config/global';
import { logger } from '../../../logger';
import { detectPlatform } from '../../../util/common';
import * as hostRules from '../../../util/host-rules';
Expand Down Expand Up @@ -154,17 +155,37 @@ export class BaseGoDatasource {
const parsedUrl = URL.parse(goSourceUrl);

// TODO: `parsedUrl.pathname` can be undefined
const packageName = trimLeadingSlash(`${parsedUrl.pathname}`);
let packageName = trimLeadingSlash(`${parsedUrl.pathname}`);

const registryUrl = `${parsedUrl.protocol}//${parsedUrl.host}`;
const endpoint = GlobalConfig.get('endpoint')!;

const endpointPrefix = regEx('https://[^/]*/(.*?/)(api/v4/?)?').exec(
endpoint,
);

if (endpointPrefix) {
packageName = packageName.replace(endpointPrefix[1], '');
}

const registryUrl = endpointPrefix
? endpoint.replace(regEx('api/v4/?$'), '')
: `${parsedUrl.protocol}//${parsedUrl.host}`;

// a .git path indicates a concrete git repository, which can be different from metadata returned by gitlab
const vcsIndicatedModule = BaseGoDatasource.gitVcsRegexp.exec(goModule);
if (vcsIndicatedModule?.groups?.module) {
if (endpointPrefix) {
packageName = vcsIndicatedModule.groups?.module.replace(
endpointPrefix[1],
'',
);
} else {
packageName = vcsIndicatedModule.groups?.module;
}
return {
datasource: GitlabTagsDatasource.id,
registryUrl,
packageName: vcsIndicatedModule.groups?.module,
packageName,
};
}

Expand Down
2 changes: 1 addition & 1 deletion lib/modules/manager/github-actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export { extractPackageFile } from './extract';

export const defaultConfig = {
fileMatch: [
'(^|/)(workflow-templates|\\.(?:github|gitea|forgejo)/workflows)/[^/]+\\.ya?ml$',
'(^|/)(workflow-templates|\\.(?:github|gitea|forgejo)/(?:workflows|actions))/.+\\.ya?ml$',
'(^|/)action\\.ya?ml$',
],
};
Expand Down
4 changes: 2 additions & 2 deletions lib/modules/platform/gerrit/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ For example, if you want to use the [Merge Confidence](https://docs.renovatebot.
Sometimes the PR title passed to the Gerrit platform code is different from the first line of the commit message.
For example:

Commit-Message=`Update keycloak.version to v21` \
Pull-Request-Title=`Update keycloak.version to v21 (major)`
- Commit-Message=`Update keycloak.version to v21`
- Pull-Request-Title=`Update keycloak.version to v21 (major)`

In this case the Gerrit-Platform implementation tries to detect this and change the commit-message in a second patch-set.
2 changes: 1 addition & 1 deletion lib/modules/platform/github/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Let Renovate use your PAT by doing _one_ of the following:

Remember to set `platform=github` somewhere in your Renovate config file.

If you use GitHub Enterprise Server then `endpoint` must point to `https://github.enterprise.com/api/v3/`.
If you use GitHub Enterprise Server then `endpoint` must point to `https://github-enterprise.example.com/api/v3/`.
You can choose where you want to set `endpoint`:

- In your `config.js` file
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@
"typescript": "5.3.3",
"unified": "9.2.2"
},
"packageManager": "pnpm@8.13.1",
"packageManager": "pnpm@8.14.0",
"files": [
"dist",
"renovate-schema.json"
Expand Down

0 comments on commit 4a0faf1

Please sign in to comment.