mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
Merge remote-tracking branch 'origin/v0.14.0rc' into refactor/auto-mode-service
This commit is contained in:
@@ -43,10 +43,14 @@ export function createInitGitHandler() {
|
||||
// .git doesn't exist, continue with initialization
|
||||
}
|
||||
|
||||
// Initialize git and create an initial empty commit
|
||||
await execAsync(`git init && git commit --allow-empty -m "Initial commit"`, {
|
||||
cwd: projectPath,
|
||||
});
|
||||
// Initialize git with 'main' as the default branch (matching GitHub's standard since 2020)
|
||||
// and create an initial empty commit
|
||||
await execAsync(
|
||||
`git init --initial-branch=main && git commit --allow-empty -m "Initial commit"`,
|
||||
{
|
||||
cwd: projectPath,
|
||||
}
|
||||
);
|
||||
|
||||
res.json({
|
||||
success: true,
|
||||
|
||||
@@ -20,8 +20,8 @@ export interface TestRepo {
|
||||
export async function createTestGitRepo(): Promise<TestRepo> {
|
||||
const tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), 'automaker-test-'));
|
||||
|
||||
// Initialize git repo
|
||||
await execAsync('git init', { cwd: tmpDir });
|
||||
// Initialize git repo with 'main' as the default branch (matching GitHub's standard)
|
||||
await execAsync('git init --initial-branch=main', { cwd: tmpDir });
|
||||
|
||||
// Use environment variables instead of git config to avoid affecting user's git config
|
||||
// These env vars override git config without modifying it
|
||||
@@ -38,9 +38,6 @@ export async function createTestGitRepo(): Promise<TestRepo> {
|
||||
await execAsync('git add .', { cwd: tmpDir, env: gitEnv });
|
||||
await execAsync('git commit -m "Initial commit"', { cwd: tmpDir, env: gitEnv });
|
||||
|
||||
// Create main branch explicitly
|
||||
await execAsync('git branch -M main', { cwd: tmpDir });
|
||||
|
||||
return {
|
||||
path: tmpDir,
|
||||
cleanup: async () => {
|
||||
|
||||
@@ -14,7 +14,8 @@ describe('worktree create route - repositories without commits', () => {
|
||||
|
||||
async function initRepoWithoutCommit() {
|
||||
repoPath = await fs.mkdtemp(path.join(os.tmpdir(), 'automaker-no-commit-'));
|
||||
await execAsync('git init', { cwd: repoPath });
|
||||
// Initialize with 'main' as the default branch (matching GitHub's standard)
|
||||
await execAsync('git init --initial-branch=main', { cwd: repoPath });
|
||||
// Don't set git config - use environment variables in commit operations instead
|
||||
// to avoid affecting user's git config
|
||||
// Intentionally skip creating an initial commit
|
||||
|
||||
@@ -30,11 +30,16 @@ import net from 'net';
|
||||
|
||||
describe('dev-server-service.ts', () => {
|
||||
let testDir: string;
|
||||
let originalHostname: string | undefined;
|
||||
|
||||
beforeEach(async () => {
|
||||
vi.clearAllMocks();
|
||||
vi.resetModules();
|
||||
|
||||
// Store and set HOSTNAME for consistent test behavior
|
||||
originalHostname = process.env.HOSTNAME;
|
||||
process.env.HOSTNAME = 'localhost';
|
||||
|
||||
testDir = path.join(os.tmpdir(), `dev-server-test-${Date.now()}`);
|
||||
await fs.mkdir(testDir, { recursive: true });
|
||||
|
||||
@@ -56,6 +61,13 @@ describe('dev-server-service.ts', () => {
|
||||
});
|
||||
|
||||
afterEach(async () => {
|
||||
// Restore original HOSTNAME
|
||||
if (originalHostname === undefined) {
|
||||
delete process.env.HOSTNAME;
|
||||
} else {
|
||||
process.env.HOSTNAME = originalHostname;
|
||||
}
|
||||
|
||||
try {
|
||||
await fs.rm(testDir, { recursive: true, force: true });
|
||||
} catch {
|
||||
|
||||
Reference in New Issue
Block a user