tools: check for Git repository in v doctor (packaged V versions often lack a .git/ folder) (fix #24419) (#24420)

This commit is contained in:
Laurent Cheylus 2025-05-05 18:44:10 +02:00 committed by GitHub
parent a1d94500e6
commit 4eed91eda1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {