Skip to content

Commit 185220e

Browse files
committed
fix: add Git installation check for checkpoints feature (#3109)
- Export checkGitInstalled() function from utils/git.ts - Add Git check before initializing checkpoint service - Show user-friendly VSCode warning when Git is not installed - Include 'Learn More' button that links to Git download page - Disable checkpoints gracefully when Git is missing This prevents silent failures and provides clear feedback to users when Git is required but not installed.
1 parent f648e4c commit 185220e

File tree

2 files changed

+50
-18
lines changed

2 files changed

+50
-18
lines changed

src/core/checkpoints/index.ts

Lines changed: 49 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { TelemetryService } from "@roo-code/telemetry"
66
import { Task } from "../task/Task"
77

88
import { getWorkspacePath } from "../../utils/path"
9+
import { checkGitInstalled } from "../../utils/git"
910

1011
import { ClineApiReqInfo } from "../../shared/ExtensionMessage"
1112
import { getApiMetrics } from "../../shared/getApiMetrics"
@@ -70,25 +71,56 @@ export function getCheckpointService(cline: Task) {
7071

7172
cline.checkpointServiceInitializing = true
7273

73-
service.on("initialize", () => {
74-
log("[Task#getCheckpointService] service initialized")
75-
76-
try {
77-
const isCheckpointNeeded =
78-
typeof cline.clineMessages.find(({ say }) => say === "checkpoint_saved") === "undefined"
79-
80-
cline.checkpointService = service
81-
cline.checkpointServiceInitializing = false
82-
83-
if (isCheckpointNeeded) {
84-
log("[Task#getCheckpointService] no checkpoints found, saving initial checkpoint")
85-
checkpointSave(cline)
74+
// Check if Git is installed before initializing the service
75+
checkGitInstalled()
76+
.then((gitInstalled) => {
77+
if (!gitInstalled) {
78+
log("[Task#getCheckpointService] Git is not installed, disabling checkpoints")
79+
cline.enableCheckpoints = false
80+
cline.checkpointServiceInitializing = false
81+
82+
// Show user-friendly notification
83+
vscode.window
84+
.showWarningMessage(
85+
"Git is required for the checkpoints feature. Please install Git to enable checkpoints.",
86+
"Learn More",
87+
)
88+
.then((selection) => {
89+
if (selection === "Learn More") {
90+
vscode.env.openExternal(vscode.Uri.parse("https://git-scm.com/downloads"))
91+
}
92+
})
93+
94+
return
8695
}
87-
} catch (err) {
88-
log("[Task#getCheckpointService] caught error in on('initialize'), disabling checkpoints")
96+
97+
// Git is installed, proceed with initialization
98+
service.on("initialize", () => {
99+
log("[Task#getCheckpointService] service initialized")
100+
101+
try {
102+
const isCheckpointNeeded =
103+
typeof cline.clineMessages.find(({ say }) => say === "checkpoint_saved") === "undefined"
104+
105+
cline.checkpointService = service
106+
cline.checkpointServiceInitializing = false
107+
108+
if (isCheckpointNeeded) {
109+
log("[Task#getCheckpointService] no checkpoints found, saving initial checkpoint")
110+
checkpointSave(cline)
111+
}
112+
} catch (err) {
113+
log("[Task#getCheckpointService] caught error in on('initialize'), disabling checkpoints")
114+
cline.enableCheckpoints = false
115+
}
116+
})
117+
})
118+
.catch((err) => {
119+
log("[Task#getCheckpointService] error checking Git installation, disabling checkpoints")
120+
console.error(err)
89121
cline.enableCheckpoints = false
90-
}
91-
})
122+
cline.checkpointServiceInitializing = false
123+
})
92124

93125
service.on("checkpoint", ({ isFirst, fromHash: from, toHash: to }) => {
94126
try {

src/utils/git.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ async function checkGitRepo(cwd: string): Promise<boolean> {
210210
}
211211
}
212212

213-
async function checkGitInstalled(): Promise<boolean> {
213+
export async function checkGitInstalled(): Promise<boolean> {
214214
try {
215215
await execAsync("git --version")
216216
return true

0 commit comments

Comments
 (0)