1818# / If you want to execute command for multiple project modules you can
1919# / specify them separated with commas (f.e. '-pm=API,WEB').
2020# / If you want to execute command for all project modules you can write '-pm=ALL'.
21+ # / This parameter can't be used with '-cpm | --current-project-module'.
22+ # /
23+ # / [-cpm | --current-project-module]
24+ # / to perform operations with current module of your mono repository project
25+ # / (in which dir you are located).
26+ # / This parameter can't be used with '-pm=<project_module>'.
2127# /
2228# / [--dont-use-git] don't use any git commands.
2329# / In this case you should run vuh in root directory (which contains .vuh)
3844# / If you want to execute command for multiple project modules you can
3945# / specify them separated with commas (f.e. '-pm=API,WEB').
4046# / If you want to execute command for all project modules you can write '-pm=ALL'.
47+ # / This parameter can't be used with '-cpm | --current-project-module'.
48+ # /
49+ # / [-cpm | --current-project-module]
50+ # / to perform operations with current module of your mono repository project
51+ # / (in which dir you are located).
52+ # / This parameter can't be used with '-pm=<project_module>'.
4153# /
4254# / [--offline | --airplane-mode]
4355# / to work offline without updating origin/MAIN_BRANCH_NAME
6072# / If you want to execute command for multiple project modules you can
6173# / specify them separated with commas (f.e. '-pm=API,WEB').
6274# / If you want to execute command for all project modules you can write '-pm=ALL'.
75+ # / This parameter can't be used with '-cpm | --current-project-module'.
76+ # /
77+ # / [-cpm | --current-project-module]
78+ # / to perform operations with current module of your mono repository project
79+ # / (in which dir you are located).
80+ # / This parameter can't be used with '-pm=<project_module>'.
6381# /
6482# / [--check-git-diff] to automatically increase version only if current branch has git difference
6583# / with HEAD..origin/MAIN_BRANCH_NAME. And if there is no git difference vuh will not
108126# / If you want to execute command for multiple project modules you can
109127# / specify them separated with commas (f.e. '-pm=API,WEB').
110128# / If you want to execute command for all project modules you can write '-pm=ALL'.
129+ # / This parameter can't be used with '-cpm | --current-project-module'.
130+ # /
131+ # / [-cpm | --current-project-module]
132+ # / to perform operations with current module of your mono repository project
133+ # / (in which dir you are located).
134+ # / This parameter can't be used with '-pm=<project_module>'.
111135# /
112136# / [--check-git-diff] to automatically increase version only if current branch has git difference
113137# / with HEAD..origin/MAIN_BRANCH_NAME. And if there is no git difference vuh will not
147171# / If you want to execute command for multiple project modules you can
148172# / specify them separated with commas (f.e. '-pm=API,WEB').
149173# / If you want to execute command for all project modules you can write '-pm=ALL'.
174+ # / This parameter can't be used with '-cpm | --current-project-module'.
175+ # /
176+ # / [-cpm | --current-project-module]
177+ # / to perform operations with current module of your mono repository project
178+ # / (in which dir you are located).
179+ # / This parameter can't be used with '-pm=<project_module>'.
150180# /
151181# / [--dont-use-git] don't use any git commands.
152182# / In this case you should run vuh in root directory (which contains .vuh)
177207# Written by Shishkin Sergey <[email protected] >178208
179209# Current vuh version
180- VUH_VERSION=' 2.10 .0'
210+ VUH_VERSION=' 2.11 .0'
181211
182212# Installation variables (Please don't modify!)
183213DATA_DIR=' <should_be_replace_after_installation:DATA_DIR>'
@@ -219,6 +249,8 @@ SPECIFIED_INCREASING_VERSION_PART='patch'
219249SPECIFIED_PROJECT_MODULE=' '
220250SPECIFIED_MAIN_BRANCH=' '
221251SPECIFIED_CONFIG_DIR=' '
252+ ARGUMENT_SPECIFIED_PROJECT_MODULE=' false'
253+ ARGUMENT_USE_CURRENT_PROJECT_MODULE=' false'
222254ARGUMENT_QUIET=' false'
223255ARGUMENT_CHECK_GIT_DIFF=' false'
224256ARGUMENT_DONT_CHECK_GIT_DIFF=' false'
@@ -421,6 +453,12 @@ function _load_project_variables_from_config() {
421453 rm -f " /tmp/${APP_NAME} _projects_conf_file"
422454 return 1
423455 }
456+ if [ " $ARGUMENT_USE_CURRENT_PROJECT_MODULE " = ' true' ]; then
457+ SPECIFIED_PROJECT_MODULE=$( _get_project_module_for_current_directory) || {
458+ _show_error_message " Failed to get project module! Current directory doesn't belong to any project module."
459+ return 1
460+ }
461+ fi
424462 rm -f " /tmp/${APP_NAME} _projects_conf_file"
425463 [ " $SPECIFIED_MULTIPLE_PROJECT_MODULES " = ' true' ] || _use_module_configuration_if_it_exists " $SPECIFIED_PROJECT_MODULE "
426464}
@@ -689,6 +727,40 @@ function _get_version_from_file() {
689727 echo " $version "
690728}
691729
730+ function _get_project_module_for_current_directory() {
731+ handling_dir=" $CUR_DIR "
732+ found_module=' false'
733+ keep_searching=' true'
734+ handling_module_root_path=' '
735+ while [ " $keep_searching " = ' true' ]; do
736+ # TODO handle case when one module is subdir of another module
737+ project_modules_without_spaces=$( echo " $PROJECT_MODULES " | tr -d " [:space:]" )
738+ IFS=' ,' read -ra ADDR <<< " $project_modules_without_spaces"
739+ for module in " ${ADDR[@]} " ; do
740+ eval handling_module_root_path=' $' " $module " ' _MODULE_ROOT_PATH'
741+ module_root_dir_for_find=" $ROOT_REPO_DIR "
742+ if [ " $handling_module_root_path " != ' ' ]; then
743+ module_root_dir_for_find=" $module_root_dir_for_find /$handling_module_root_path "
744+ 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'
750+ fi
751+ # _use_module_configuration "$next_handling_module" || return 1
752+ done
753+ if [ " $handling_dir " = ' /' ] || [ " $handling_dir " = " $ROOT_REPO_DIR " ]; then
754+ keep_searching=' false'
755+ fi
756+ handling_dir=" $( dirname " $handling_dir " ) "
757+ done
758+ if [ " $found_module " = ' false' ]; then
759+ _show_error_message " Failed to get any module root path which could contain your current path!"
760+ return 1
761+ fi
762+ }
763+
692764function _fetch_remote_branches() {
693765 git fetch -q || {
694766 _show_error_message ' Failed to use "git fetch" to update information about remote branches!'
@@ -1226,6 +1298,8 @@ while [[ $# -gt 0 ]]; do
12261298 shift ;;
12271299 -pm=* )
12281300 _check_arg " $1 "
1301+ _show_cant_use_both_arguments ' --current-project-module' ' -pm=' " $ARGUMENT_USE_CURRENT_PROJECT_MODULE " ' false'
1302+ ARGUMENT_SPECIFIED_PROJECT_MODULE=' true'
12291303 SPECIFIED_PROJECT_MODULE=${1#* =}
12301304 if [[ " $SPECIFIED_PROJECT_MODULE " == * " ," * ]]; then
12311305 SPECIFIED_MULTIPLE_PROJECT_MODULES=' true'
@@ -1234,6 +1308,11 @@ while [[ $# -gt 0 ]]; do
12341308 SPECIFIED_MULTIPLE_PROJECT_MODULES=' true'
12351309 fi
12361310 shift ;;
1311+ -cpm|--current-project-module)
1312+ _check_arg " $1 "
1313+ _show_cant_use_both_arguments ' -pm=' ' --current-project-module' " $ARGUMENT_SPECIFIED_PROJECT_MODULE " ' false'
1314+ ARGUMENT_USE_CURRENT_PROJECT_MODULE=' true'
1315+ shift ;;
12371316 -q|--quiet)
12381317 _check_arg " $1 "
12391318 ARGUMENT_QUIET=' true'
0 commit comments