Skip to content

Commit

Permalink
tools.vpm: improve version detection of installed modules (#19933)
Browse files Browse the repository at this point in the history
  • Loading branch information
ttytm committed Nov 19, 2023
1 parent 09c65a7 commit 8267874
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions cmd/tools/vpm/common.v
Expand Up @@ -95,7 +95,7 @@ fn parse_query(query []string) ([]Module, []Module) {
mut details := ''
if resp := http.head('${info.url}/issues/new') {
if resp.status_code == 200 {
issue_tmpl_url := '${info.url}/issues/new?title=Missing%20Manifest&body=${info.name}%20is%20missing%20a%20manifest,%20please%20consider%20adding%20a%20v.mod%20file%20with%20the%20modules%20metadta.'
issue_tmpl_url := '${info.url}/issues/new?title=Missing%20Manifest&body=${info.name}%20is%20missing%20a%20manifest,%20please%20consider%20adding%20a%20v.mod%20file%20with%20the%20modules%20metadata.'
details = 'Help to ensure future-compatibility by adding a `v.mod` file or opening an issue at:\n`${issue_tmpl_url}`'
}
}
Expand All @@ -110,9 +110,23 @@ fn parse_query(query []string) ([]Module, []Module) {
}
}
mod.version = version
if v := os.execute_opt('git ls-remote --tags ${mod.install_path}') {
if refs := os.execute_opt('git ls-remote --refs ${mod.install_path}') {
mod.is_installed = true
mod.installed_version = v.output.all_after_last('/').trim_space()
// In case the head just temporarily matches a tag, make sure that there
// really is a version installation before adding it as `installed_version`.
// NOTE: can be refined for branch installations. E.g., for `sdl`.
if refs.output.contains('refs/tags/') {
tag := refs.output.all_after_last('refs/tags/').trim_space()
head := if refs.output.contains('refs/heads/') {
refs.output.all_after_last('refs/heads/').trim_space()
} else {
tag
}
vpm_log(@FILE_LINE, @FN, 'head: ${head}, tag: ${tag}')
if tag == head {
mod.installed_version = tag
}
}
}
if mod.is_external {
external_modules << mod
Expand Down

0 comments on commit 8267874

Please sign in to comment.