From 9c53d8686fc6fa22c7b0c8810b16ec0a35ebde73 Mon Sep 17 00:00:00 2001 From: Zbigniew Sobiecki Date: Mon, 23 Feb 2026 08:22:41 +0000 Subject: [PATCH] fix(repo): clone repository on configured baseBranch instead of default cloneRepo() always cloned the GitHub default branch, ignoring the project's baseBranch setting from the database. This meant projects configured with e.g. baseBranch=develop would still start work from main. Pass --branch to git clone so the checkout always matches the project config. Also fixes a pre-existing lint warning (noExplicitAny) in the ack message generator test. Co-Authored-By: Claude Opus 4.6 --- src/utils/repo.ts | 5 +++-- tests/unit/router/ackMessageGenerator.test.ts | 6 ++--- tests/unit/utils/repo.test.ts | 22 +++++++++++++++++-- 3 files changed, 26 insertions(+), 7 deletions(-) diff --git a/src/utils/repo.ts b/src/utils/repo.ts index 98bb64e1..9f2d5e0c 100644 --- a/src/utils/repo.ts +++ b/src/utils/repo.ts @@ -41,9 +41,10 @@ export async function cloneRepo( const cloneToken = token ?? (await getProjectGitHubToken(project)); const cloneUrl = `https://${cloneToken}@github.com/${project.repo}.git`; - logger.info('Cloning repository', { repo: project.repo, targetDir }); + const branch = project.baseBranch ?? 'main'; + logger.info('Cloning repository', { repo: project.repo, targetDir, branch }); - execSync(`git clone ${cloneUrl} ${targetDir}`, { + execSync(`git clone --branch ${branch} ${cloneUrl} ${targetDir}`, { stdio: 'pipe', env: { ...process.env }, }); diff --git a/tests/unit/router/ackMessageGenerator.test.ts b/tests/unit/router/ackMessageGenerator.test.ts index 4cec7f74..d2e165ba 100644 --- a/tests/unit/router/ackMessageGenerator.test.ts +++ b/tests/unit/router/ackMessageGenerator.test.ts @@ -46,9 +46,9 @@ import { generateAckMessage, } from '../../../src/router/ackMessageGenerator.js'; -// Access llmist mocks — biome-ignore lint/suspicious/noExplicitAny: accessing test-only mock internals -const llmistModule = (await import('llmist')) as Record; -const mockRun = llmistModule.__mockRun; +// Access llmist mocks — test-only mock internals +const llmistModule = (await import('llmist')) as Record; +const mockRun = llmistModule.__mockRun as ReturnType; beforeEach(() => { vi.clearAllMocks(); diff --git a/tests/unit/utils/repo.test.ts b/tests/unit/utils/repo.test.ts index 8047f93c..a773e6bf 100644 --- a/tests/unit/utils/repo.test.ts +++ b/tests/unit/utils/repo.test.ts @@ -102,7 +102,7 @@ describe('repo utils', () => { }); describe('cloneRepo', () => { - it('clones repo and configures git user', async () => { + it('clones repo on baseBranch and configures git user', async () => { const project = { id: 'test', name: 'Test', @@ -115,7 +115,7 @@ describe('repo utils', () => { await cloneRepo(project, '/tmp/repo'); expect(execSync).toHaveBeenCalledWith( - expect.stringContaining('git clone'), + expect.stringContaining('git clone --branch main'), expect.objectContaining({ stdio: 'pipe' }), ); expect(execSync).toHaveBeenCalledWith( @@ -127,6 +127,24 @@ describe('repo utils', () => { expect.objectContaining({ cwd: '/tmp/repo' }), ); }); + + it('clones repo on non-default baseBranch', async () => { + const project = { + id: 'test', + name: 'Test', + repo: 'owner/repo', + baseBranch: 'develop', + branchPrefix: 'feature/', + trello: { boardId: 'board', lists: {}, labels: {} }, + }; + + await cloneRepo(project, '/tmp/repo'); + + expect(execSync).toHaveBeenCalledWith( + expect.stringContaining('git clone --branch develop'), + expect.objectContaining({ stdio: 'pipe' }), + ); + }); }); describe('cleanupTempDir', () => {