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
5 changes: 5 additions & 0 deletions .bumpy/fix-internal-authors.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@varlock/bumpy': patch
---

Fix `internalAuthors` option being ignored by the GitHub changelog formatter. The `loadFormatter` function matched the built-in "github" entry before reaching the options-aware path, so options like `internalAuthors` were silently dropped.
14 changes: 7 additions & 7 deletions packages/bumpy/src/core/changelog.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,13 @@ const BUILTIN_FORMATTERS: Record<string, ChangelogFormatter | (() => Promise<Cha
export async function loadFormatter(changelog: BumpyConfig['changelog'], rootDir: string): Promise<ChangelogFormatter> {
const [name, options] = Array.isArray(changelog) ? changelog : [changelog, {}];

// Built-in formatter
// Built-in with options (e.g., ["github", { repo: "..." }])
if (name === 'github') {
const { createGithubFormatter } = await import('./changelog-github.ts');
return createGithubFormatter(options as import('./changelog-github.ts').GithubChangelogOptions);
}

// Built-in formatter (no options)
if (typeof name === 'string' && BUILTIN_FORMATTERS[name]) {
const builtin = BUILTIN_FORMATTERS[name];
if (typeof builtin === 'function' && builtin.length === 0) {
Expand All @@ -84,12 +90,6 @@ export async function loadFormatter(changelog: BumpyConfig['changelog'], rootDir
return builtin as ChangelogFormatter;
}

// Built-in with options (e.g., ["github", { repo: "..." }])
if (name === 'github') {
const { createGithubFormatter } = await import('./changelog-github.ts');
return createGithubFormatter(options as import('./changelog-github.ts').GithubChangelogOptions);
}

// Custom module
if (typeof name === 'string') {
try {
Expand Down
59 changes: 57 additions & 2 deletions packages/bumpy/test/core/changelog.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
import { test, expect, describe } from 'bun:test';
import { test, expect, describe, beforeEach, afterEach } from 'bun:test';
import { makeRelease, makeBumpFile } from '../helpers.ts';
import { defaultFormatter, generateChangelogEntry, prependToChangelog } from '../../src/core/changelog.ts';
import { installShellMock, uninstallShellMock, addMockRule } from '../helpers-shell-mock.ts';
import {
defaultFormatter,
generateChangelogEntry,
loadFormatter,
prependToChangelog,
} from '../../src/core/changelog.ts';

describe('defaultFormatter', () => {
test('formats basic release with bump files', async () => {
Expand Down Expand Up @@ -154,3 +160,52 @@ describe('prependToChangelog', () => {
expect(result).toContain('- New entry');
});
});

describe('loadFormatter', () => {
beforeEach(() => {
installShellMock();
addMockRule({ match: 'gh repo view', response: 'dmno-dev/bumpy' });
});

afterEach(() => {
uninstallShellMock();
});

test('passes options through to github formatter', async () => {
addMockRule({ match: /^git log/, response: '' });

const formatter = await loadFormatter(
['github', { internalAuthors: ['theoephraim'], repo: 'dmno-dev/bumpy' }],
'/tmp',
);
const release = makeRelease('pkg-a', '1.0.1', { bumpFiles: ['cs1'] });
const bumpFiles = [makeBumpFile('cs1', [{ name: 'pkg-a', type: 'patch' }], 'author: @theoephraim\nFixed it')];

const result = await formatter({ release, bumpFiles, date: '2026-04-14' });

expect(result).not.toContain('Thanks');
});

test('github formatter without options still works', async () => {
addMockRule({ match: /^git log/, response: '' });

const formatter = await loadFormatter('github', '/tmp');
const release = makeRelease('pkg-a', '1.0.1', { bumpFiles: ['cs1'] });
const bumpFiles = [makeBumpFile('cs1', [{ name: 'pkg-a', type: 'patch' }], 'author: @someone\nFixed it')];

const result = await formatter({ release, bumpFiles, date: '2026-04-14' });

expect(result).toContain('Thanks [@someone]');
});

test('loads default formatter by name', async () => {
const formatter = await loadFormatter('default', '/tmp');
const release = makeRelease('pkg-a', '1.0.0', { bumpFiles: ['cs1'] });
const bumpFiles = [makeBumpFile('cs1', [{ name: 'pkg-a', type: 'patch' }], 'A fix')];

const result = await formatter({ release, bumpFiles, date: '2026-04-14' });

expect(result).toContain('## 1.0.0');
expect(result).toContain('- A fix');
});
});