Skip to content

Commit 4eed91e

Browse files
authored
tools: check for Git repository in v doctor (packaged V versions often lack a .git/ folder) (fix #24419) (#24420)
1 parent a1d9450 commit 4eed91e

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

‎cmd/tools/vdoctor.v‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,11 @@ fn (mut a App) cpu_info(key string) string {
237237
}
238238

239239
fn (mut a App) git_info() string {
240+
// Check if in a Git repository
241+
x := os.execute('git rev-parse --is-inside-work-tree')
242+
if x.exit_code != 0 || x.output.trim_space() != 'true' {
243+
return 'N/A'
244+
}
240245
mut out := a.cmd(command: 'git -C . describe --abbrev=8 --dirty --always --tags').trim_space()
241246
os.execute('git -C . remote add V_REPO https://github.com/vlang/v') // ignore failure (i.e. remote exists)
242247
if '-skip-github' !in os.args {

0 commit comments

Comments
 (0)