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

feat!: v39 #32273

Merged
merged 6 commits into from
Nov 4, 2024
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ concurrency:

env:
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
NODE_VERSION: 20
NODE_VERSION: 22
PDM_VERSION: 2.20.0.post1 # renovate: datasource=pypi depName=pdm
DRY_RUN: true
TEST_LEGACY_DECRYPTION: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-data.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
workflow_dispatch:

env:
NODE_VERSION: 20
NODE_VERSION: 22

permissions:
contents: read
Expand Down
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.18.0
22.11.0
7 changes: 6 additions & 1 deletion docs/usage/configuration-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,12 @@ If `true`, Renovate removes special characters when slugifying the branch name:
- only alphabetic characters are allowed
- hyphens `-` are used to separate sections

The default `false` behavior will mean that special characters like `.` may end up in the branch name.
The default `false` behavior will mean that special characters like `.` and `/` may end up in the branch name.

<!-- prettier-ignore -->
!!! note
Renovate will not apply any search/replace to the `branchPrefix` part of the branch name.
If you don't want any `/` in your branch name then you will also need to change `branchPrefix` from the default `renovate/` value to something like `renovate-`.

## branchPrefix

Expand Down
2 changes: 1 addition & 1 deletion docs/usage/examples/self-hosting.md
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,7 @@ COPY self-signed-certificate.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates
# Change back to the Ubuntu user
USER 1000
USER 12021
# OpenSSL
ENV SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
Expand Down
2 changes: 1 addition & 1 deletion lib/config/options/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ const options: RenovateOptions[] = [
description:
'Change this value to override the default Renovate sidecar image.',
type: 'string',
default: 'ghcr.io/containerbase/sidecar:11.11.41',
default: 'ghcr.io/containerbase/sidecar:13.0.4',
globalOnly: true,
},
{
Expand Down
36 changes: 18 additions & 18 deletions lib/modules/platform/github/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ describe('modules/platform/github/index', () => {
}

describe('initRepo', () => {
it('should rebase', async () => {
it('should squash', async () => {
const scope = httpMock.scope(githubApiHost);
initRepoMock(scope, 'some/repo');
const config = await github.initRepo({ repository: 'some/repo' });
Expand Down Expand Up @@ -675,7 +675,7 @@ describe('modules/platform/github/index', () => {
expect(config).toMatchSnapshot();
});

it('should squash', async () => {
it('should merge', async () => {
httpMock
.scope(githubApiHost)
.post(`/graphql`)
Expand All @@ -687,8 +687,8 @@ describe('modules/platform/github/index', () => {
nameWithOwner: 'some/repo',
hasIssuesEnabled: true,
mergeCommitAllowed: true,
rebaseMergeAllowed: false,
squashMergeAllowed: true,
rebaseMergeAllowed: true,
squashMergeAllowed: false,
defaultBranchRef: {
name: 'master',
target: {
Expand All @@ -704,7 +704,7 @@ describe('modules/platform/github/index', () => {
expect(config).toMatchSnapshot();
});

it('should merge', async () => {
it('should rebase', async () => {
httpMock
.scope(githubApiHost)
.post(`/graphql`)
Expand All @@ -715,8 +715,8 @@ describe('modules/platform/github/index', () => {
isArchived: false,
nameWithOwner: 'some/repo',
hasIssuesEnabled: true,
mergeCommitAllowed: true,
rebaseMergeAllowed: false,
mergeCommitAllowed: false,
rebaseMergeAllowed: true,
squashMergeAllowed: false,
defaultBranchRef: {
name: 'master',
Expand Down Expand Up @@ -2882,7 +2882,7 @@ describe('modules/platform/github/index', () => {
},
variables: {
pullRequestId: 'abcd',
mergeMethod: 'REBASE',
mergeMethod: 'SQUASH',
},
},
};
Expand Down Expand Up @@ -3510,7 +3510,7 @@ describe('modules/platform/github/index', () => {
},
variables: {
pullRequestId: 'abcd',
mergeMethod: 'REBASE',
mergeMethod: 'SQUASH',
},
},
};
Expand Down Expand Up @@ -3683,7 +3683,7 @@ describe('modules/platform/github/index', () => {
});

describe('mergePr(prNo) - autodetection', () => {
it('should try rebase first', async () => {
it('should try squash first', async () => {
const scope = httpMock.scope(githubApiHost);
initRepoMock(scope, 'some/repo');
scope.put('/repos/some/repo/pulls/1235/merge').reply(200);
Expand All @@ -3702,12 +3702,12 @@ describe('modules/platform/github/index', () => {
).toBeTrue();
});

it('should try squash after rebase', async () => {
it('should try merge after squash', async () => {
const scope = httpMock.scope(githubApiHost);
initRepoMock(scope, 'some/repo');
scope
.put('/repos/some/repo/pulls/1236/merge')
.reply(400, 'no rebasing allowed');
.reply(400, 'no squashing allowed');
await github.initRepo({ repository: 'some/repo' });
const pr = {
number: 1236,
Expand All @@ -3723,15 +3723,15 @@ describe('modules/platform/github/index', () => {
).toBeFalse();
});

it('should try merge after squash', async () => {
it('should try rebase after merge', async () => {
const scope = httpMock.scope(githubApiHost);
initRepoMock(scope, 'some/repo');
scope
.put('/repos/some/repo/pulls/1237/merge')
.reply(405, 'no rebasing allowed')
.put('/repos/some/repo/pulls/1237/merge')
.reply(405, 'no squashing allowed')
.put('/repos/some/repo/pulls/1237/merge')
.reply(405, 'no merging allowed')
.put('/repos/some/repo/pulls/1237/merge')
.reply(200);
await github.initRepo({ repository: 'some/repo' });
const pr = {
Expand All @@ -3753,12 +3753,12 @@ describe('modules/platform/github/index', () => {
initRepoMock(scope, 'some/repo');
scope
.put('/repos/some/repo/pulls/1237/merge')
.reply(405, 'no rebasing allowed')
.put('/repos/some/repo/pulls/1237/merge')
.replyWithError('no squashing allowed')
.reply(405, 'no squashing allowed')
.put('/repos/some/repo/pulls/1237/merge')
.replyWithError('no merging allowed')
.put('/repos/some/repo/pulls/1237/merge')
.replyWithError('no rebasing allowed')
.put('/repos/some/repo/pulls/1237/merge')
.replyWithError('never gonna give you up');
await github.initRepo({ repository: 'some/repo' });
const pr = {
Expand Down
20 changes: 10 additions & 10 deletions lib/modules/platform/github/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -553,12 +553,12 @@ export async function initRepo({
// Base branch may be configured but defaultBranch is always fixed
logger.debug(`${repository} default branch = ${config.defaultBranch}`);
// GitHub allows administrators to block certain types of merge, so we need to check it
if (repo.rebaseMergeAllowed) {
config.mergeMethod = 'rebase';
} else if (repo.squashMergeAllowed) {
if (repo.squashMergeAllowed) {
config.mergeMethod = 'squash';
} else if (repo.mergeCommitAllowed) {
config.mergeMethod = 'merge';
} else if (repo.rebaseMergeAllowed) {
config.mergeMethod = 'rebase';
} else {
// This happens if we don't have Administrator read access, it is not a critical error
logger.debug('Could not find allowed merge methods for repo');
Expand Down Expand Up @@ -1910,25 +1910,25 @@ export async function mergePr({
}
}
if (!automerged) {
// We need to guess the merge method and try squash -> rebase -> merge
options.body.merge_method = 'rebase';
// We need to guess the merge method and try squash -> merge -> rebase
options.body.merge_method = 'squash';
try {
logger.debug({ options, url }, `mergePr`);
automergeResult = await githubApi.putJson(url, options);
} catch (err1) {
logger.debug({ err: err1 }, `Failed to rebase merge PR`);
logger.debug({ err: err1 }, `Failed to squash merge PR`);
try {
options.body.merge_method = 'squash';
options.body.merge_method = 'merge';
logger.debug({ options, url }, `mergePr`);
automergeResult = await githubApi.putJson(url, options);
} catch (err2) {
logger.debug({ err: err2 }, `Failed to merge squash PR`);
logger.debug({ err: err2 }, `Failed to merge commit PR`);
try {
options.body.merge_method = 'merge';
options.body.merge_method = 'rebase';
logger.debug({ options, url }, `mergePr`);
automergeResult = await githubApi.putJson(url, options);
} catch (err3) {
logger.debug({ err: err3 }, `Failed to merge commit PR`);
logger.debug({ err: err3 }, `Failed to rebase merge PR`);
logger.info({ pr: prNo }, 'All merge attempts failed');
return false;
}
Expand Down
16 changes: 16 additions & 0 deletions lib/workers/repository/updates/branch-name.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,22 @@ describe('workers/repository/updates/branch-name', () => {
expect(upgrade.branchName).toBe('renovate/jest-42-x');
});

it('removes slashes from the non-suffix part', () => {
const upgrade: RenovateConfig = {
branchNameStrict: true,
branchName:
'{{{branchPrefix}}}{{{additionalBranchPrefix}}}{{{branchTopic}}}',
branchTopic:
'{{{depNameSanitized}}}-{{{newMajor}}}{{#if isPatch}}.{{{newMinor}}}{{/if}}.x{{#if isLockfileUpdate}}-lockfile{{/if}}',
branchPrefix: 'renovate/',
depNameSanitized: '@foo/jest',
newMajor: '42',
group: {},
};
generateBranchName(upgrade);
expect(upgrade.branchName).toBe('renovate/foo-jest-42-x');
});

it('hashedBranchLength hashing', () => {
const upgrade: RenovateConfig = {
branchName:
Expand Down
13 changes: 11 additions & 2 deletions lib/workers/repository/updates/branch-name.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const MIN_HASH_LENGTH = 6;

const RE_MULTIPLE_DASH = regEx(/--+/g);

const RE_SPECIAL_CHARS_STRICT = regEx(/[`~!@#$%^&*()_=+[\]\\|{};':",.<>?]/g);
const RE_SPECIAL_CHARS_STRICT = regEx(/[`~!@#$%^&*()_=+[\]\\|{};':",.<>?/]/g);

/**
* Clean git branch name
Expand All @@ -26,12 +26,20 @@ const RE_SPECIAL_CHARS_STRICT = regEx(/[`~!@#$%^&*()_=+[\]\\|{};':",.<>?]/g);
*/
function cleanBranchName(
branchName: string,
branchPrefix: string,
branchNameStrict?: boolean,
): string {
let cleanedBranchName = branchName;

let existingBranchPrefix = '';
if (branchNameStrict) {
cleanedBranchName = cleanedBranchName.replace(RE_SPECIAL_CHARS_STRICT, '-'); // massage out all special characters that slip through slugify
if (cleanedBranchName.startsWith(branchPrefix)) {
existingBranchPrefix = branchPrefix;
cleanedBranchName = cleanedBranchName.slice(branchPrefix.length);
}
cleanedBranchName =
existingBranchPrefix +
cleanedBranchName.replace(RE_SPECIAL_CHARS_STRICT, '-'); // massage out all special characters that slip through slugify
}

return cleanGitRef
Expand Down Expand Up @@ -125,6 +133,7 @@ export function generateBranchName(update: RenovateConfig): void {
}
update.branchName = cleanBranchName(
update.branchName,
update.branchPrefix!,
update.branchNameStrict,
);
}
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@
},
"homepage": "https://renovatebot.com",
"engines": {
"node": "^20.15.1",
"node": "^20.15.1 || ^22.11.0",
rarkins marked this conversation as resolved.
Show resolved Hide resolved
"pnpm": "^9.0.0"
},
"volta": {
"node": "20.18.0",
"node": "22.11.0",
"pnpm": "9.12.3"
},
"dependencies": {
Expand Down
12 changes: 7 additions & 5 deletions tools/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@ ARG BASE_IMAGE_TYPE=slim
# --------------------------------------
# slim image
# --------------------------------------
FROM ghcr.io/renovatebot/base-image:7.41.2@sha256:b104d2a8ae0072f205f29b972769e4c1a00d9957073b628b57c734e4f7376027 AS slim-base
FROM ghcr.io/renovatebot/base-image:9.2.0@sha256:52c241a927ca9f2e339e8d74c860f410c2f182a19819fb2050f89c91a905d99f AS slim-base
viceice marked this conversation as resolved.
Show resolved Hide resolved

# --------------------------------------
# full image
# --------------------------------------
FROM ghcr.io/renovatebot/base-image:7.41.2-full@sha256:3365becc7d7b50b210f793e58e4e871ead00976280f3451fd97230417c02f423 AS full-base
FROM ghcr.io/renovatebot/base-image:9.2.0-full@sha256:898a5898727ef6ecbe3d57c6dcf9917b13af91abc11f70e6c9926c7ebf1b0311 AS full-base

ENV RENOVATE_BINARY_SOURCE=global

# --------------------------------------
# build image
# --------------------------------------
FROM --platform=$BUILDPLATFORM ghcr.io/renovatebot/base-image:7.41.2@sha256:b104d2a8ae0072f205f29b972769e4c1a00d9957073b628b57c734e4f7376027 AS build
FROM --platform=$BUILDPLATFORM ghcr.io/renovatebot/base-image:9.2.0@sha256:52c241a927ca9f2e339e8d74c860f410c2f182a19819fb2050f89c91a905d99f AS build

# We want a specific node version here
# renovate: datasource=node-version
RUN install-tool node 20.18.0
RUN install-tool node 22.11.0

WORKDIR /usr/local/renovate

Expand Down Expand Up @@ -102,4 +104,4 @@ LABEL \
org.label-schema.version="${RENOVATE_VERSION}"

# Numeric user ID for the ubuntu user. Used to indicate a non-root user to OpenShift
USER 1000
USER 12021