Skip to content

Commit bd2e87f

Browse files
authored
feat: add changelogContent property (renovatebot#36340)
1 parent 8ace166 commit bd2e87f

File tree

7 files changed

+109
-1
lines changed

7 files changed

+109
-1
lines changed

lib/modules/datasource/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ export interface GetPkgReleasesConfig {
5555
}
5656

5757
export interface Release {
58+
changelogContent?: string;
5859
changelogUrl?: string;
5960
checksumUrl?: string;
6061
downloadUrl?: string;
@@ -81,6 +82,7 @@ export interface ReleaseResult {
8182
isPrivate?: boolean;
8283
releases: Release[];
8384
tags?: Record<string, string> | undefined;
85+
changelogContent?: string;
8486
// URL metadata
8587
changelogUrl?: string;
8688
dependencyUrl?: string;

lib/workers/repository/changelog/index.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,27 @@ describe('workers/repository/changelog/index', () => {
1919
partial<BranchUpgradeConfig>({ logJSON: null }),
2020
partial<BranchUpgradeConfig>(),
2121
partial<BranchUpgradeConfig>(),
22+
partial<BranchUpgradeConfig>({ changelogContent: 'testContent' }),
2223
];
2324
await expect(embedChangelogs(branches)).toResolve();
2425
expect(branches).toEqual([
2526
{ logJSON: null },
2627
{ logJSON: { hasReleaseNotes: true } },
2728
{ logJSON: null },
29+
{
30+
changelogContent: 'testContent',
31+
logJSON: {
32+
hasReleaseNotes: true,
33+
project: {},
34+
versions: [
35+
{
36+
releaseNotes: {
37+
body: 'testContent',
38+
},
39+
},
40+
],
41+
},
42+
},
2843
]);
2944
});
3045
});

lib/workers/repository/changelog/index.ts

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,38 @@ export async function embedChangelog(
99
if (upgrade.logJSON !== undefined) {
1010
return;
1111
}
12-
upgrade.logJSON = await getChangeLogJSON(upgrade);
12+
13+
if (upgrade.changelogContent === undefined) {
14+
upgrade.logJSON = await getChangeLogJSON(upgrade);
15+
} else {
16+
upgrade.logJSON = {
17+
hasReleaseNotes: true,
18+
project: {
19+
packageName: upgrade.packageName,
20+
depName: upgrade.depName,
21+
type: undefined!,
22+
apiBaseUrl: undefined!,
23+
baseUrl: undefined!,
24+
repository: upgrade.repository!,
25+
sourceUrl: upgrade.sourceUrl!,
26+
sourceDirectory: upgrade.sourceDirectory,
27+
},
28+
versions: [
29+
{
30+
changes: undefined!,
31+
compare: undefined!,
32+
date: undefined!,
33+
releaseNotes: {
34+
body: upgrade.changelogContent,
35+
notesSourceUrl: undefined!,
36+
url: upgrade.changelogUrl!,
37+
},
38+
gitRef: undefined!,
39+
version: upgrade.newVersion!,
40+
},
41+
],
42+
};
43+
}
1344
}
1445

1546
export async function embedChangelogs(

lib/workers/repository/process/lookup/index.spec.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5452,5 +5452,51 @@ describe('workers/repository/process/lookup/index', () => {
54525452
},
54535453
]);
54545454
});
5455+
5456+
it('handles changelog with content', async () => {
5457+
config.currentValue = '8.0.0';
5458+
config.packageName = 'node';
5459+
config.datasource = DockerDatasource.id;
5460+
getDockerReleases.mockResolvedValueOnce({
5461+
releases: [
5462+
{
5463+
version: '8.0.0',
5464+
},
5465+
{
5466+
changelogContent: 'testContent',
5467+
changelogUrl: 'http://testChangelogUrl',
5468+
version: '8.1.0',
5469+
},
5470+
],
5471+
});
5472+
5473+
const res = await Result.wrap(
5474+
lookup.lookupUpdates(config),
5475+
).unwrapOrThrow();
5476+
5477+
expect(res).toEqual({
5478+
changelogContent: 'testContent',
5479+
changelogUrl: 'http://testChangelogUrl',
5480+
currentVersion: '8.0.0',
5481+
fixedVersion: '8.0.0',
5482+
isSingleVersion: true,
5483+
registryUrl: 'https://index.docker.io',
5484+
sourceUrl: 'https://github.com/nodejs/node',
5485+
updates: [
5486+
{
5487+
bucket: 'non-major',
5488+
isBreaking: false,
5489+
newMajor: 8,
5490+
newMinor: 1,
5491+
newPatch: 0,
5492+
newValue: '8.1.0',
5493+
newVersion: '8.1.0',
5494+
updateType: 'minor',
5495+
},
5496+
],
5497+
versioning: 'npm',
5498+
warnings: [],
5499+
});
5500+
});
54555501
});
54565502
});

lib/workers/repository/process/lookup/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,18 @@ export async function lookupUpdates(
760760
/* istanbul ignore next */ update.updateType !== 'rollback',
761761
);
762762
}
763+
764+
const release =
765+
res.updates.length > 0
766+
? dependency?.releases.find(
767+
(r) => r.version === res.updates[0].newValue,
768+
)
769+
: null;
770+
771+
if (release?.changelogContent) {
772+
res.changelogContent = release.changelogContent;
773+
res.changelogUrl = release.changelogUrl;
774+
}
763775
} catch (err) /* istanbul ignore next */ {
764776
if (err instanceof ExternalHostError) {
765777
return Result.err(err);

lib/workers/repository/process/lookup/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface LookupUpdateConfig
5858

5959
export interface UpdateResult {
6060
sourceDirectory?: string;
61+
changelogContent?: string;
6162
changelogUrl?: string;
6263
dependencyUrl?: string;
6364
homepage?: string;

lib/workers/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ export interface BranchUpgradeConfig
7979

8080
hasReleaseNotes?: boolean;
8181
homepage?: string;
82+
changelogContent?: string;
8283
changelogUrl?: string;
8384
dependencyUrl?: string;
8485
sourceUrl?: string;

0 commit comments

Comments
 (0)