Skip to content

Commit 2f73bd8

Browse files
committed
Fix default branch check to use defaultBranch parameter instead of hardcoded values
1 parent b53e89c commit 2f73bd8

File tree

2 files changed

+25
-3
lines changed

2 files changed

+25
-3
lines changed

src/check-dependency-bumps.test.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,28 @@ describe('check-dependency-bumps', () => {
4949
expect(result).toStrictEqual({});
5050
});
5151

52+
it('returns empty object when on custom defaultBranch without fromRef', async () => {
53+
const stdoutWriteSpy = jest.spyOn(stdout, 'write');
54+
jest
55+
.spyOn(repoModule, 'getCurrentBranchName')
56+
.mockResolvedValue('develop');
57+
58+
const result = await checkDependencyBumps({
59+
defaultBranch: 'develop',
60+
projectRoot: '/path/to/project',
61+
stdout,
62+
stderr,
63+
});
64+
65+
expect(result).toStrictEqual({});
66+
expect(stdoutWriteSpy).toHaveBeenCalledWith(
67+
expect.stringContaining('📌 Current branch: develop'),
68+
);
69+
expect(stdoutWriteSpy).toHaveBeenCalledWith(
70+
expect.stringContaining('⚠️ You are on the develop branch'),
71+
);
72+
});
73+
5274
it('auto-detects merge base when fromRef is not provided', async () => {
5375
const stdoutWriteSpy = jest.spyOn(stdout, 'write');
5476
const getStdoutSpy = jest.spyOn(miscUtilsModule, 'getStdoutFromCommand');

src/check-dependency-bumps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,10 @@ export async function checkDependencyBumps({
296296
const currentBranch = await getCurrentBranchName(projectRoot);
297297
stdout.write(`\n📌 Current branch: ${currentBranch}\n`);
298298

299-
// Skip if we're on main/master
300-
if (currentBranch === 'main' || currentBranch === 'master') {
299+
// Skip if we're on the default branch
300+
if (currentBranch === defaultBranch) {
301301
stdout.write(
302-
'⚠️ You are on the main/master branch. Please specify commits to compare or switch to a feature branch.\n',
302+
`⚠️ You are on the ${defaultBranch} branch. Please specify commits to compare or switch to a feature branch.\n`,
303303
);
304304
return {};
305305
}

0 commit comments

Comments
 (0)