From 6044c1af743bd99169bb3a8e0c33abd7295a9aab Mon Sep 17 00:00:00 2001 From: Will Li Date: Sun, 13 Jul 2025 15:26:24 -0700 Subject: [PATCH] initial print fix --- src/services/checkpoints/ShadowCheckpointService.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/services/checkpoints/ShadowCheckpointService.ts b/src/services/checkpoints/ShadowCheckpointService.ts index be2c86852a..89ba1a54ab 100644 --- a/src/services/checkpoints/ShadowCheckpointService.ts +++ b/src/services/checkpoints/ShadowCheckpointService.ts @@ -20,6 +20,7 @@ export abstract class ShadowCheckpointService extends EventEmitter { protected _checkpoints: string[] = [] protected _baseHash?: string + protected _hasFirstCheckpoint: boolean = false protected readonly dotGitDir: string protected git?: SimpleGit @@ -93,6 +94,11 @@ export abstract class ShadowCheckpointService extends EventEmitter { await this.writeExcludeFile() this.baseHash = await git.revparse(["HEAD"]) + // Check if there are any commits beyond the initial commit + const commits = await git.log() + if (commits.total > 0) { + this._hasFirstCheckpoint = true + } } else { this.log(`[${this.constructor.name}#initShadowGit] creating shadow git repo at ${this.checkpointsDir}`) await git.init() @@ -211,7 +217,7 @@ export abstract class ShadowCheckpointService extends EventEmitter { await this.stageAll(this.git) const commitArgs = options?.allowEmpty ? { "--allow-empty": null } : undefined const result = await this.git.commit(message, commitArgs) - const isFirst = this._checkpoints.length === 0 + const isFirst = !this._hasFirstCheckpoint const fromHash = this._checkpoints[this._checkpoints.length - 1] ?? this.baseHash! const toHash = result.commit || fromHash this._checkpoints.push(toHash) @@ -219,6 +225,9 @@ export abstract class ShadowCheckpointService extends EventEmitter { if (isFirst || result.commit) { this.emit("checkpoint", { type: "checkpoint", isFirst, fromHash, toHash, duration }) + if (isFirst) { + this._hasFirstCheckpoint = true + } } if (result.commit) {