From 4eed91eda1e135880a4f99256e4d6704a37784e8 Mon Sep 17 00:00:00 2001 From: Laurent Cheylus Date: Mon, 5 May 2025 18:44:10 +0200 Subject: [PATCH] tools: check for Git repository in `v doctor` (packaged V versions often lack a .git/ folder) (fix #24419) (#24420) --- cmd/tools/vdoctor.v | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/tools/vdoctor.v b/cmd/tools/vdoctor.v index c5a9529e4c..b28600db52 100644 --- a/cmd/tools/vdoctor.v +++ b/cmd/tools/vdoctor.v @@ -237,6 +237,11 @@ fn (mut a App) cpu_info(key string) string { } fn (mut a App) git_info() string { + // Check if in a Git repository + x := os.execute('git rev-parse --is-inside-work-tree') + if x.exit_code != 0 || x.output.trim_space() != 'true' { + return 'N/A' + } mut out := a.cmd(command: 'git -C . describe --abbrev=8 --dirty --always --tags').trim_space() os.execute('git -C . remote add V_REPO https://github.com/vlang/v') // ignore failure (i.e. remote exists) if '-skip-github' !in os.args {