mirror of
https://github.com/RooVetGit/Roo-Code.git
synced 2026-09-07 08:26:51 +00:00
Check for empty stash commits
This commit is contained in:
parent
6b351876e7
commit
37c2a1760b
2 changed files with 17 additions and 6 deletions
|
|
@ -218,7 +218,7 @@ export class CheckpointService {
|
|||
this.log(
|
||||
`[saveCheckpoint] failed in stage stash phase: ${err instanceof Error ? err.message : String(err)}`,
|
||||
)
|
||||
await this.git.checkout(["-f", this.mainBranch])
|
||||
await this.restoreMain({ branch: stashBranch, stashSha, force: true })
|
||||
await this.git.branch(["-D", stashBranch]).catch(() => {})
|
||||
throw err
|
||||
}
|
||||
|
|
@ -232,19 +232,27 @@ export class CheckpointService {
|
|||
* - UNDO: Create branch
|
||||
* - UNDO: Change branch
|
||||
*/
|
||||
let stashCommit
|
||||
|
||||
try {
|
||||
// TODO: Add a test to see if empty commits break this.
|
||||
const stashCommit = await this.git.commit(message, undefined, { "--no-verify": null })
|
||||
stashCommit = await this.git.commit(message, undefined, { "--no-verify": null })
|
||||
this.log(`[saveCheckpoint] stashCommit: ${message} -> ${JSON.stringify(stashCommit)}`)
|
||||
} catch (err) {
|
||||
this.log(
|
||||
`[saveCheckpoint] failed in stash commit phase: ${err instanceof Error ? err.message : String(err)}`,
|
||||
)
|
||||
await this.git.checkout(["-f", this.mainBranch])
|
||||
await this.restoreMain({ branch: stashBranch, stashSha, force: true })
|
||||
await this.git.branch(["-D", stashBranch]).catch(() => {})
|
||||
throw err
|
||||
}
|
||||
|
||||
if (!stashCommit) {
|
||||
this.log("[saveCheckpoint] no stash commit")
|
||||
await this.restoreMain({ branch: stashBranch, stashSha })
|
||||
await this.git.branch(["-D", stashBranch])
|
||||
return undefined
|
||||
}
|
||||
|
||||
/**
|
||||
* PHASE: Diff
|
||||
* Mutations:
|
||||
|
|
|
|||
|
|
@ -210,9 +210,12 @@ describe("CheckpointService", () => {
|
|||
})
|
||||
|
||||
it("does not create a checkpoint if there are no pending changes", async () => {
|
||||
const commit0 = await service.saveCheckpoint("Zeroth checkpoint")
|
||||
expect(commit0?.commit).toBeFalsy()
|
||||
|
||||
await fs.writeFile(testFile, "Ahoy, world!")
|
||||
const commit = await service.saveCheckpoint("First checkpoint")
|
||||
expect(commit?.commit).toBeTruthy()
|
||||
const commit1 = await service.saveCheckpoint("First checkpoint")
|
||||
expect(commit1?.commit).toBeTruthy()
|
||||
|
||||
const commit2 = await service.saveCheckpoint("Second checkpoint")
|
||||
expect(commit2?.commit).toBeFalsy()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue