mirror of
https://github.com/renovatebot/renovate.git
synced 2026-10-25 15:01:49 +00:00
feat(changelogs): Include depName in release name patterns (#30395)
This commit is contained in:
@@ -600,7 +600,7 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('gets release notes with body "other-"', async () => {
|
||||
it('gets release notes with body "other-" (packageName)', async () => {
|
||||
githubReleasesMock.mockResolvedValueOnce([
|
||||
{
|
||||
version: 'other-1.0.0',
|
||||
@@ -644,6 +644,51 @@ describe('workers/repository/update/pr/changelog/release-notes', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('gets release notes with body "other-" (depName)', async () => {
|
||||
githubReleasesMock.mockResolvedValueOnce([
|
||||
{
|
||||
version: 'other-1.0.0',
|
||||
releaseTimestamp: '2020-01-01',
|
||||
id: 1,
|
||||
url: 'https://github.com/some/other-repository/releases/other-1.0.0',
|
||||
name: 'some/dep',
|
||||
description: 'some body',
|
||||
},
|
||||
{
|
||||
version: 'other-1.0.1',
|
||||
releaseTimestamp: '2020-01-01',
|
||||
id: 2,
|
||||
url: 'https://github.com/some/other-repository/releases/other-1.0.1',
|
||||
name: 'some/dep',
|
||||
description:
|
||||
'some body #123, [#124](https://github.com/some/yet-other-repository/issues/124)',
|
||||
},
|
||||
]);
|
||||
|
||||
const res = await getReleaseNotes(
|
||||
{
|
||||
...githubProject,
|
||||
repository: 'some/other-repository',
|
||||
packageName: 'some.registry/some/other',
|
||||
depName: 'other',
|
||||
},
|
||||
partial<ChangeLogRelease>({
|
||||
version: '1.0.1',
|
||||
gitRef: '1.0.1',
|
||||
}),
|
||||
partial<BranchUpgradeConfig>(),
|
||||
);
|
||||
expect(res).toEqual({
|
||||
body: 'some body [#123](https://github.com/some/other-repository/issues/123), [#124](https://github.com/some/yet-other-repository/issues/124)\n',
|
||||
id: 2,
|
||||
name: 'some/dep',
|
||||
notesSourceUrl:
|
||||
'https://api.github.com/repos/some/other-repository/releases',
|
||||
tag: 'other-1.0.1',
|
||||
url: 'https://github.com/some/other-repository/releases/other-1.0.1',
|
||||
});
|
||||
});
|
||||
|
||||
it('gets release notes with body "other_v"', async () => {
|
||||
githubReleasesMock.mockResolvedValueOnce([
|
||||
{
|
||||
|
||||
@@ -132,15 +132,22 @@ export async function getReleaseNotes(
|
||||
release: ChangeLogRelease,
|
||||
config: BranchUpgradeConfig,
|
||||
): Promise<ChangeLogNotes | null> {
|
||||
const { packageName, repository } = project;
|
||||
const { packageName, depName, repository } = project;
|
||||
const { version, gitRef } = release;
|
||||
// TODO: types (#22198)
|
||||
logger.trace(`getReleaseNotes(${repository}, ${version}, ${packageName!})`);
|
||||
logger.trace(
|
||||
`getReleaseNotes(${repository}, ${version}, ${packageName!}, ${depName!})`,
|
||||
);
|
||||
const releases = await getCachedReleaseList(project, release);
|
||||
logger.trace({ releases }, 'Release list from getReleaseList');
|
||||
let releaseNotes: ChangeLogNotes | null = null;
|
||||
|
||||
let matchedRelease = getExactReleaseMatch(packageName!, version, releases);
|
||||
let matchedRelease = getExactReleaseMatch(
|
||||
packageName!,
|
||||
depName!,
|
||||
version,
|
||||
releases,
|
||||
);
|
||||
if (is.undefined(matchedRelease)) {
|
||||
// no exact match of a release then check other cases
|
||||
matchedRelease = releases.find(
|
||||
@@ -166,10 +173,13 @@ export async function getReleaseNotes(
|
||||
|
||||
function getExactReleaseMatch(
|
||||
packageName: string,
|
||||
depName: string,
|
||||
version: string,
|
||||
releases: ChangeLogNotes[],
|
||||
): ChangeLogNotes | undefined {
|
||||
const exactReleaseReg = regEx(`${packageName}[@_-]v?${version}`);
|
||||
const exactReleaseReg = regEx(
|
||||
`(?:^|/)(?:${packageName}|${depName})[@_-]v?${version}`,
|
||||
);
|
||||
const candidateReleases = releases.filter((r) => r.tag?.endsWith(version));
|
||||
const matchedRelease = candidateReleases.find((r) =>
|
||||
exactReleaseReg.test(r.tag!),
|
||||
|
||||
@@ -74,6 +74,7 @@ export abstract class ChangeLogSource {
|
||||
const newVersion = config.newVersion!;
|
||||
const sourceUrl = config.sourceUrl!;
|
||||
const packageName = config.packageName!;
|
||||
const depName = config.depName!;
|
||||
const sourceDirectory = config.sourceDirectory;
|
||||
const version = allVersioning.get(versioning);
|
||||
|
||||
@@ -111,7 +112,9 @@ export abstract class ChangeLogSource {
|
||||
.sort((a, b) => version.sortVersions(a.version, b.version));
|
||||
|
||||
if (validReleases.length < 2) {
|
||||
logger.debug(`Not enough valid releases for dep ${packageName}`);
|
||||
logger.debug(
|
||||
`Not enough valid releases for dep ${depName} (${packageName})`,
|
||||
);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -143,8 +146,8 @@ export abstract class ChangeLogSource {
|
||||
compare: {},
|
||||
};
|
||||
const tags = await getTags();
|
||||
const prevHead = this.getRef(version, packageName, prev, tags);
|
||||
const nextHead = this.getRef(version, packageName, next, tags);
|
||||
const prevHead = this.getRef(version, packageName, depName, prev, tags);
|
||||
const nextHead = this.getRef(version, packageName, depName, next, tags);
|
||||
if (is.nonEmptyString(prevHead) && is.nonEmptyString(nextHead)) {
|
||||
release.compare.url = this.getCompareURL(
|
||||
baseUrl,
|
||||
@@ -185,11 +188,13 @@ export abstract class ChangeLogSource {
|
||||
private findTagOfRelease(
|
||||
version: allVersioning.VersioningApi,
|
||||
packageName: string,
|
||||
depName: string,
|
||||
depNewVersion: string,
|
||||
tags: string[],
|
||||
): string | undefined {
|
||||
const regex = regEx(`(?:${packageName}|release)[@-]`, undefined, false);
|
||||
const exactReleaseRegex = regEx(`${packageName}[@\\-_]v?${depNewVersion}`);
|
||||
const releaseRegexPrefix = `^(?:${packageName}|${depName}|release)[@_-]v?`;
|
||||
const regex = regEx(releaseRegexPrefix, undefined, false);
|
||||
const exactReleaseRegex = regEx(`${releaseRegexPrefix}${depNewVersion}`);
|
||||
const exactTagsList = tags.filter((tag) => {
|
||||
return exactReleaseRegex.test(tag);
|
||||
});
|
||||
@@ -202,12 +207,14 @@ export abstract class ChangeLogSource {
|
||||
private getRef(
|
||||
version: allVersioning.VersioningApi,
|
||||
packageName: string,
|
||||
depName: string,
|
||||
release: Release,
|
||||
tags: string[],
|
||||
): string | null {
|
||||
const tagName = this.findTagOfRelease(
|
||||
version,
|
||||
packageName,
|
||||
depName,
|
||||
release.version,
|
||||
tags,
|
||||
);
|
||||
|
||||
@@ -27,6 +27,7 @@ export type ChangeLogPlatform = 'bitbucket' | 'gitea' | 'github' | 'gitlab';
|
||||
|
||||
export interface ChangeLogProject {
|
||||
packageName?: string;
|
||||
depName?: string;
|
||||
type: ChangeLogPlatform;
|
||||
apiBaseUrl: string;
|
||||
baseUrl: string;
|
||||
|
||||
Reference in New Issue
Block a user