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: 3 additions & 2 deletions src/utils/repo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
});
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/router/ackMessageGenerator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, any>;
const mockRun = llmistModule.__mockRun;
// Access llmist mocks — test-only mock internals
const llmistModule = (await import('llmist')) as Record<string, unknown>;
const mockRun = llmistModule.__mockRun as ReturnType<typeof vi.fn>;

beforeEach(() => {
vi.clearAllMocks();
Expand Down
22 changes: 20 additions & 2 deletions tests/unit/utils/repo.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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(
Expand All @@ -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', () => {
Expand Down