Skip to content

Commit 6044c1a

Browse files
committed
initial print fix
1 parent 0872b8b commit 6044c1a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/services/checkpoints/ShadowCheckpointService.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export abstract class ShadowCheckpointService extends EventEmitter {
2020

2121
protected _checkpoints: string[] = []
2222
protected _baseHash?: string
23+
protected _hasFirstCheckpoint: boolean = false
2324

2425
protected readonly dotGitDir: string
2526
protected git?: SimpleGit
@@ -93,6 +94,11 @@ export abstract class ShadowCheckpointService extends EventEmitter {
9394

9495
await this.writeExcludeFile()
9596
this.baseHash = await git.revparse(["HEAD"])
97+
// Check if there are any commits beyond the initial commit
98+
const commits = await git.log()
99+
if (commits.total > 0) {
100+
this._hasFirstCheckpoint = true
101+
}
96102
} else {
97103
this.log(`[${this.constructor.name}#initShadowGit] creating shadow git repo at ${this.checkpointsDir}`)
98104
await git.init()
@@ -211,14 +217,17 @@ export abstract class ShadowCheckpointService extends EventEmitter {
211217
await this.stageAll(this.git)
212218
const commitArgs = options?.allowEmpty ? { "--allow-empty": null } : undefined
213219
const result = await this.git.commit(message, commitArgs)
214-
const isFirst = this._checkpoints.length === 0
220+
const isFirst = !this._hasFirstCheckpoint
215221
const fromHash = this._checkpoints[this._checkpoints.length - 1] ?? this.baseHash!
216222
const toHash = result.commit || fromHash
217223
this._checkpoints.push(toHash)
218224
const duration = Date.now() - startTime
219225

220226
if (isFirst || result.commit) {
221227
this.emit("checkpoint", { type: "checkpoint", isFirst, fromHash, toHash, duration })
228+
if (isFirst) {
229+
this._hasFirstCheckpoint = true
230+
}
222231
}
223232

224233
if (result.commit) {

0 commit comments

Comments
 (0)