From 46a096b95d6fdfcd09c0ea203d3af86da27c06ad Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Mon, 31 Jan 2022 06:57:50 +0200 Subject: [PATCH] Revert "v.util: make mod_path_to_full_name more robust" This reverts commit b11ce91141dcc6adc51d8afc4f1bfc6746cb07c6. --- cmd/v/v.v | 2 +- examples/submodule/.v.mod.stop | 0 examples/submodule/v.mod | 0 vlib/v/util/module.v | 27 ++------------------------- 4 files changed, 3 insertions(+), 26 deletions(-) delete mode 100644 examples/submodule/.v.mod.stop delete mode 100644 examples/submodule/v.mod diff --git a/cmd/v/v.v b/cmd/v/v.v index e0e55ba625..b20c1167fb 100644 --- a/cmd/v/v.v +++ b/cmd/v/v.v @@ -3,7 +3,7 @@ // that can be found in the LICENSE file. module main -import cmd.v.help +import help import os import term import v.pref diff --git a/examples/submodule/.v.mod.stop b/examples/submodule/.v.mod.stop deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/examples/submodule/v.mod b/examples/submodule/v.mod deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/vlib/v/util/module.v b/vlib/v/util/module.v index de9a8c60ca..0454878a4b 100644 --- a/vlib/v/util/module.v +++ b/vlib/v/util/module.v @@ -113,7 +113,6 @@ fn mod_path_to_full_name(pref &pref.Preferences, mod string, path string) ?strin break } } - // start_info := '> in_vmod_path: ${in_vmod_path:-6} | mod: ${mod:-21} | path: ${path:-58}' path_parts := path.split(os.path_separator) mod_path := mod.replace('.', os.path_separator) // go back through each parent in path_parts and join with `mod_path` to see the dir exists @@ -129,7 +128,6 @@ fn mod_path_to_full_name(pref &pref.Preferences, mod string, path string) ?strin // we reached a vmod folder if path_part in vmod_folders { mod_full_name := try_path.split(os.path_separator)[j + 1..].join('.') - // eprintln('$start_info >>>> mod_full_name 1: $mod_full_name , in vmod_folders') return mod_full_name } } @@ -141,38 +139,19 @@ fn mod_path_to_full_name(pref &pref.Preferences, mod string, path string) ?strin mut last_v_mod := -1 for j := try_path_parts.len; j > 0; j-- { parent := try_path_parts[0..j].join(os.path_separator) - // eprintln(' >>> i: $i | try_path: $try_path | trying parent $j: $parent') if ls := os.ls(parent) { - mut found_stop := false - for x in ls { - if x in ['.git', '.hg', '.svn', '.v.mod.stop'] { - found_stop = true - break - } - } // currently CI clones some modules into the v repo to test, the condition // after `'v.mod' in ls` can be removed once a proper solution is added if 'v.mod' in ls && (try_path_parts.len > i && try_path_parts[i] != 'v' && 'vlib' !in ls) { - // eprintln('>>> v.mod found') last_v_mod = j } - if found_stop { - if last_v_mod > -1 { - mod_full_name := try_path_parts[last_v_mod..].join('.') - // eprintln('$start_info >>>> mod_full_name 2: $mod_full_name , .v.mod.stop reached in folder: $parent, last_v_mod: $last_v_mod') - return mod_full_name - } - mod_full_name := try_path_parts[j..].join('.') - return mod_full_name - } continue } break } if last_v_mod > -1 { mod_full_name := try_path_parts[last_v_mod..].join('.') - // eprintln('$start_info >>>> mod_full_name 3: $mod_full_name , last_v_mod was $last_v_mod') return mod_full_name } } @@ -182,11 +161,9 @@ fn mod_path_to_full_name(pref &pref.Preferences, mod string, path string) ?strin rel_mod_path := path.replace(pref.path.all_before_last(os.path_separator) + os.path_separator, '') if rel_mod_path != path { - mod_full_name := rel_mod_path.replace(os.path_separator, '.') - // eprintln('$start_info >>>> mod_full_name 4: $mod_full_name, abs_path: $pref.path') - return mod_full_name + full_mod_name := rel_mod_path.replace(os.path_separator, '.') + return full_mod_name } } - // eprintln('$start_info >>>> error module not found') return error('module not found') }