File tree Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Expand file tree Collapse file tree 2 files changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -56,6 +56,10 @@ fn parse_query(query []string) ([]Module, []Module) {
56
56
errors++
57
57
continue
58
58
}
59
+ if ! has_vmod (ident) {
60
+ errors++
61
+ continue
62
+ }
59
63
Module{
60
64
name: name
61
65
url: ident
@@ -93,6 +97,25 @@ fn parse_query(query []string) ([]Module, []Module) {
93
97
return vpm_modules, extended_modules
94
98
}
95
99
100
+ fn has_vmod (url string ) bool {
101
+ head_branch := os.execute_opt ('git ls-remote --symref ${url} HEAD' ) or {
102
+ vpm_error ('failed to find git HEAD for `${url} `.' , details: err.msg ())
103
+ return false
104
+ }.output.all_after_last ('/' ).all_before (' ' ).all_before ('\t ' )
105
+ url_ := if url.ends_with ('.git' ) { url.replace ('.git' , '' ) } else { url }
106
+ manifest_url := '${url_} /blob/${head_branch} /v.mod'
107
+ vpm_log (@FILE_LINE, @FN, 'manifest_url: ${manifest_url} ' )
108
+ has_vmod := http.head (manifest_url) or {
109
+ vpm_error ('failed to retrieve module data for `${url} `.' )
110
+ return false
111
+ }.status_code == 200
112
+ if ! has_vmod {
113
+ vpm_error ('failed to find `v.mod` for `${url} `.' )
114
+ return false
115
+ }
116
+ return true
117
+ }
118
+
96
119
fn get_mod_date_info (mut pp pool.PoolProcessor, idx int , wid int ) & ModuleDateInfo {
97
120
mut result := & ModuleDateInfo{
98
121
name: pp.get_item[string ](idx)
Original file line number Diff line number Diff line change 1
1
// vtest flaky: true
2
2
// vtest retry: 3
3
+ module main
4
+
3
5
import os
4
6
import v.vmod
5
7
@@ -108,3 +110,12 @@ fn test_missing_repo_name_in_url() {
108
110
assert res.exit_code == 1
109
111
assert res.output.contains ('failed to retrieve module name for `${incomplete_url} `' )
110
112
}
113
+
114
+ fn test_missing_vmod_in_url () {
115
+ assert has_vmod ('https://github.com/vlang/v' ) // head branch == `master`.
116
+ assert has_vmod ('https://github.com/v-analyzer/v-analyzer' ) // head branch == `main`.
117
+ assert ! has_vmod ('https://github.com/octocat/octocat.github.io' ) // not a V module.
118
+ res := os.execute ('${v} install https://github.com/octocat/octocat.github.io' )
119
+ assert res.exit_code == 1
120
+ assert res.output.contains ('failed to find `v.mod` for `https://github.com/octocat/octocat.github.io`' ), res.output
121
+ }
You can’t perform that action at this time.
0 commit comments