Skip to content
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
11 changes: 10 additions & 1 deletion dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -105558,7 +105558,16 @@ function loadOrBuildManifest(github, inputs) {
}
: {};
core.debug('Loading manifest from config file');
return release_please_1.Manifest.fromManifest(github, github.repository.defaultBranch, inputs.configFile, inputs.manifestFile, manifestOverrides);
return release_please_1.Manifest.fromManifest(github, github.repository.defaultBranch, inputs.configFile, inputs.manifestFile, manifestOverrides).then(manifest => {
// Override changelogHost for all paths if provided as action input and different from default
if (inputs.changelogHost && inputs.changelogHost !== DEFAULT_GITHUB_SERVER_URL) {
core.debug(`Overriding changelogHost to: ${inputs.changelogHost}`);
for (const path in manifest.repositoryConfig) {
manifest.repositoryConfig[path].changelogHost = inputs.changelogHost;
}
}
return manifest;
});
}
async function main(fetchOverride) {
core.info(`Running release-please version: ${release_please_1.VERSION}`);
Expand Down
11 changes: 10 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,16 @@ function loadOrBuildManifest(
inputs.configFile,
inputs.manifestFile,
manifestOverrides
);
).then(manifest => {
// Override changelogHost for all paths if provided as action input and different from default
if (inputs.changelogHost && inputs.changelogHost !== DEFAULT_GITHUB_SERVER_URL) {
core.debug(`Overriding changelogHost to: ${inputs.changelogHost}`);
for (const path in manifest.repositoryConfig) {
manifest.repositoryConfig[path].changelogHost = inputs.changelogHost;
}
}
return manifest;
});
}

export async function main(fetchOverride?: any) {
Expand Down
73 changes: 73 additions & 0 deletions test/release-please.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,79 @@ describe('release-please-action', () => {
sinon.match({fork: true}),
);
});
it('allows specifying changelog-host', async () => {
restoreEnv = mockInputs({
'changelog-host': 'https://ghe.example.com',
});
fakeManifest.createReleases.resolves([]);
fakeManifest.createPullRequests.resolves([]);
await action.main(fetch);
sinon.assert.calledOnce(fakeManifest.createReleases);
sinon.assert.calledOnce(fakeManifest.createPullRequests);

// Test that fromManifest is called without changelogHost in overrides
// This assertion verifies that changelogHost is not passed in the manifestOverrides
// because the implementation handles changelogHost by modifying the manifest
// after it's created, not by passing it as an override parameter.
sinon.assert.calledWith(
fromManifestStub,
sinon.match.any,
sinon.match.string,
sinon.match.string,
sinon.match.string,
sinon.match(arg => !arg.hasOwnProperty('changelogHost')),
);
});
it('modifies repositoryConfig with custom changelog-host', async () => {
restoreEnv = mockInputs({
'changelog-host': 'https://ghe.example.com',
});

// Create a mock repositoryConfig on the existing fakeManifest
const mockRepositoryConfig = {
'.': { releaseType: 'node' },
'packages/foo': { releaseType: 'node' }
};
// Use Object.defineProperty to set the readonly property
Object.defineProperty(fakeManifest, 'repositoryConfig', {
value: mockRepositoryConfig,
writable: true,
configurable: true
});
fakeManifest.createReleases.resolves([]);
fakeManifest.createPullRequests.resolves([]);

await action.main(fetch);

// Verify that changelogHost was added to all paths in repositoryConfig
assert.strictEqual(fakeManifest.repositoryConfig['.'].changelogHost, 'https://ghe.example.com');
assert.strictEqual(fakeManifest.repositoryConfig['packages/foo'].changelogHost, 'https://ghe.example.com');
});
it('does not modify repositoryConfig when changelog-host is default', async () => {
restoreEnv = mockInputs({
'changelog-host': 'https://github.com', // This is the default
});

// Create a mock repositoryConfig on the existing fakeManifest
const mockRepositoryConfig = {
'.': { releaseType: 'node' },
'packages/foo': { releaseType: 'node' }
};
// Use Object.defineProperty to set the readonly property
Object.defineProperty(fakeManifest, 'repositoryConfig', {
value: mockRepositoryConfig,
writable: true,
configurable: true
});
fakeManifest.createReleases.resolves([]);
fakeManifest.createPullRequests.resolves([]);

await action.main(fetch);

// Verify that changelogHost was NOT added when using default value
assert.strictEqual(fakeManifest.repositoryConfig['.'].changelogHost, undefined);
assert.strictEqual(fakeManifest.repositoryConfig['packages/foo'].changelogHost, undefined);
});
});

it('allows specifying manifest config paths', async () => {
Expand Down
Loading