@@ -9,12 +9,6 @@ if (process.env.NODE_ENV !== "test") {
99 debug . enable ( "simple-git" )
1010}
1111
12- export interface Checkpoint {
13- hash : string
14- message : string
15- timestamp ?: Date
16- }
17-
1812export type CheckpointServiceOptions = {
1913 taskId : string
2014 git ?: SimpleGit
@@ -60,6 +54,16 @@ export type CheckpointServiceOptions = {
6054 */
6155
6256export class CheckpointService {
57+ private _currentCheckpoint ?: string
58+
59+ public get currentCheckpoint ( ) {
60+ return this . _currentCheckpoint
61+ }
62+
63+ private set currentCheckpoint ( value : string | undefined ) {
64+ this . _currentCheckpoint = value
65+ }
66+
6367 constructor (
6468 public readonly taskId : string ,
6569 private readonly git : SimpleGit ,
@@ -217,6 +221,8 @@ export class CheckpointService {
217221 await this . popStash ( )
218222 }
219223
224+ this . currentCheckpoint = commit . commit
225+
220226 return commit
221227 } catch ( err ) {
222228 this . log ( `[saveCheckpoint] Failed to save checkpoint: ${ err instanceof Error ? err . message : String ( err ) } ` )
@@ -237,6 +243,7 @@ export class CheckpointService {
237243 await this . ensureBranch ( this . mainBranch )
238244 await this . git . clean ( [ CleanOptions . FORCE , CleanOptions . RECURSIVE ] )
239245 await this . git . raw ( [ "restore" , "--source" , commitHash , "--worktree" , "--" , "." ] )
246+ this . currentCheckpoint = commitHash
240247 }
241248
242249 public static async create ( { taskId, git, baseDir, log = console . log } : CheckpointServiceOptions ) {
@@ -291,7 +298,7 @@ export class CheckpointService {
291298 // the checkpoint (i.e. the `git restore` command doesn't work
292299 // for empty commits).
293300 await fs . writeFile ( path . join ( baseDir , ".gitkeep" ) , "" )
294- await git . add ( "." )
301+ await git . add ( ".gitkeep " )
295302 const commit = await git . commit ( "Initial commit" )
296303
297304 if ( ! commit . commit ) {
0 commit comments