@@ -4,11 +4,7 @@ import * as fs from 'fs/promises';
44import * as path from 'path' ;
55
66export 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