Skip to content

Commit 81ac691

Browse files
committed
Fixes rebase e2e tests
1 parent deec2fa commit 81ac691

File tree

3 files changed

+227
-347
lines changed

3 files changed

+227
-347
lines changed

tests/e2e/baseTest.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ export const test = base.extend<BaseFixtures, WorkerFixtures>({
179179
});
180180
// Cleanup after test
181181
for (const repo of repos) {
182-
await fs.promises.rm(repo.repoDir, { recursive: true, force: true }).catch(() => {});
182+
await fs.promises.rm(repo.repoPath, { recursive: true, force: true }).catch(() => {});
183183
}
184184
},
185185

tests/e2e/fixtures/git.ts

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,7 @@ import * as fs from 'fs/promises';
44
import * as path from 'path';
55

66
export class GitFixture {
7-
constructor(private readonly repoPath: string) {}
8-
9-
get repoDir(): string {
10-
return this.repoPath;
11-
}
7+
constructor(public readonly repoPath: string) {}
128

139
async init(): Promise<void> {
1410
await fs.mkdir(this.repoPath, { recursive: true });
@@ -188,6 +184,29 @@ export class GitFixture {
188184
}
189185
}
190186

187+
/**
188+
* Clean up all Git rebase state files and directories.
189+
* This is useful for ensuring a clean state between tests.
190+
*/
191+
async cleanupRebaseState(): Promise<void> {
192+
try {
193+
await fs.rm(path.join(this.repoPath, '.git', 'rebase-merge'), { recursive: true, force: true });
194+
} catch {}
195+
try {
196+
await fs.rm(path.join(this.repoPath, '.git', 'rebase-apply'), { recursive: true, force: true });
197+
} catch {}
198+
try {
199+
await fs.unlink(path.join(this.repoPath, '.git', 'REBASE_HEAD'));
200+
} catch {}
201+
try {
202+
await fs.unlink(path.join(this.repoPath, '.git', 'index.lock'));
203+
} catch {}
204+
try {
205+
await fs.unlink(path.join(this.repoPath, '.git', 'HEAD.lock'));
206+
} catch {}
207+
await new Promise(resolve => setTimeout(resolve, 500));
208+
}
209+
191210
/**
192211
* Reset the repository to a specific ref
193212
* @param ref The ref to reset to (default: HEAD)

0 commit comments

Comments
 (0)