Skip to content

Commit 153e716

Browse files
authored
Merge pull request #40 from Greewil/fixes
Operations with multiple modules if -cpm used in dir which belongs to multiples roots
2 parents bafbc91 + 53d7fb8 commit 153e716

File tree

5 files changed

+30
-11
lines changed

5 files changed

+30
-11
lines changed

.github/workflows/unit-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
runs-on: ubuntu-latest
1010
strategy:
1111
matrix:
12-
test_group: ['bo', 'ci', 'sv', 'cc', 'mr', 'mmo', 'nrd', 'cgd', 'cgdmr', 'of', 'ae']
12+
test_group: ['bo', 'ci', 'sv', 'cc', 'mr', 'mmo', 'nrd', 'rdi', 'cgd', 'cgdmr', 'of', 'ae']
1313
steps:
1414
- name: Checkout
1515
uses: actions/checkout@v4

installer-tests/run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function _show_success_message() {
8383
function _show_invalid_usage_error_message() {
8484
message=$1
8585
_show_error_message "$message"
86-
_show_info_message 'Use "vuh --help" to see available commands and options information'
86+
_show_info_message 'Use "./run_tests.sh --help" to see available commands and options information'
8787
}
8888

8989
function _exit_if_using_multiple_commands() {

unit-tests/assert_data.csv

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,18 @@ nrd9, monorepo_equals, 2.2.3, no,
115115
nrd10, monorepo_equals, 3.2.2, no, yes, cd module_3; {{vuh}} uv -q -cpm
116116

117117

118+
# root dir intersections
119+
rdi1, monorepo_same_root_dirs, 2.2.2, no, no, cd module_2; {{vuh}} lv -q -cpm
120+
rdi2, monorepo_same_root_dirs, 2.2.3, no, no, cd module_2; {{vuh}} sv -q -cpm
121+
rdi3, monorepo_same_root_dirs, 2.2.3, no, yes, cd module_2; {{vuh}} uv -q -cpm
122+
rdi4, monorepo_same_root_dirs, 1.2.3 3.2.1, no, no, cd module_1_3; {{vuh}} lv -q -cpm | tr '\n' ' '
123+
rdi5, monorepo_same_root_dirs, 1.2.4 3.2.2, no, no, cd module_1_3; {{vuh}} sv -q -cpm | tr '\n' ' '
124+
rdi6, monorepo_same_root_dirs, 1.2.4 3.2.2, no, yes, cd module_1_3; {{vuh}} uv -q -cpm | tr '\n' ' '
125+
rdi7, monorepo_root_dir_intersection, 1.2.3 2.2.2 3.2.1, no, no, cd module_2/module_1_3; {{vuh}} lv -q -cpm | tr '\n' ' '
126+
rdi8, monorepo_root_dir_intersection, 1.2.4 2.2.3 3.2.2, no, no, cd module_2/module_1_3; {{vuh}} sv -q -cpm | tr '\n' ' '
127+
rdi9, monorepo_root_dir_intersection, 1.2.4 2.2.3 3.2.2, no, yes, cd module_2/module_1_3; {{vuh}} uv -q -cpm | tr '\n' ' '
128+
129+
118130
# check git diff
119131
cgd1, versions_equal, 1.2.3, no, no, {{vuh}} sv -q --check-git-diff
120132
cgd2, check_git_diff_equal, 1.2.3, no, no, {{vuh}} sv -q

unit-tests/run_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ function _show_success_message() {
8383
function _show_invalid_usage_error_message() {
8484
message=$1
8585
_show_error_message "$message"
86-
_show_info_message 'Use "vuh --help" to see available commands and options information'
86+
_show_info_message 'Use "./run_tests.sh --help" to see available commands and options information'
8787
}
8888

8989
function _show_cant_use_both_arguments() {

vuh.sh

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
# Written by Shishkin Sergey <[email protected]>
208208

209209
# Current vuh version
210-
VUH_VERSION='2.11.2'
210+
VUH_VERSION='2.12.0'
211211

212212
# Installation variables (Please don't modify!)
213213
DATA_DIR='<should_be_replace_after_installation:DATA_DIR>'
@@ -458,6 +458,13 @@ function _load_project_variables_from_config() {
458458
_show_error_message "Failed to get project module! Current directory doesn't belong to any project module."
459459
return 1
460460
}
461+
if [ "$(echo "$SPECIFIED_PROJECT_MODULE" | wc -l)" != "1" ]; then
462+
_show_info_message "Current directory owned by multiple modules:"
463+
_show_info_message "$SPECIFIED_PROJECT_MODULE"
464+
SPECIFIED_PROJECT_MODULE="$(echo "$SPECIFIED_PROJECT_MODULE" | tr '\n' ',')"
465+
SPECIFIED_MULTIPLE_PROJECT_MODULES='true'
466+
_handle_multiple_modules_call || exit 1
467+
fi
461468
fi
462469
rm -f "/tmp/${APP_NAME}_projects_conf_file"
463470
[ "$SPECIFIED_MULTIPLE_PROJECT_MODULES" = 'true' ] || _use_module_configuration_if_it_exists "$SPECIFIED_PROJECT_MODULE"
@@ -733,7 +740,6 @@ function _get_project_module_for_current_directory() {
733740
keep_searching='true'
734741
handling_module_root_path=''
735742
while [ "$keep_searching" = 'true' ]; do
736-
# TODO handle case when one module is subdir of another module
737743
project_modules_without_spaces=$(echo "$PROJECT_MODULES" | tr -d "[:space:]")
738744
IFS=',' read -ra ADDR <<< "$project_modules_without_spaces"
739745
for module in "${ADDR[@]}"; do
@@ -742,13 +748,14 @@ function _get_project_module_for_current_directory() {
742748
if [ "$handling_module_root_path" != '' ]; then
743749
module_root_dir_for_find="$module_root_dir_for_find/$handling_module_root_path"
744750
fi
745-
find_result=$(find "$module_root_dir_for_find" -type d -wholename "$handling_dir")
746-
if [ "$find_result" != '' ]; then
747-
echo "$module"
748-
found_module='true'
749-
keep_searching='false'
751+
if [ -d "$module_root_dir_for_find" ] || [ -f "$module_root_dir_for_find" ]; then
752+
find_result=$(find "$module_root_dir_for_find" -type d -wholename "$handling_dir")
753+
if [ "$find_result" != '' ]; then
754+
echo "$module"
755+
found_module='true'
756+
keep_searching='false'
757+
fi
750758
fi
751-
# _use_module_configuration "$next_handling_module" || return 1
752759
done
753760
if [ "$handling_dir" = '/' ] || [ "$handling_dir" = "$ROOT_REPO_DIR" ]; then
754761
keep_searching='false'

0 commit comments

Comments
 (0)