Skip to content

Commit c4a8913

Browse files
committed
fix: fixed issues with ubtaining versions from remote branches
Fixed issue with unstable fetching. Fixed issue with getting romoute .vuh config from any directory.
1 parent b030738 commit c4a8913

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

vuh.sh

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@
162162
# Written by Shishkin Sergey <[email protected]>
163163

164164
# Current vuh version
165-
VUH_VERSION='2.9.1'
165+
VUH_VERSION='2.9.2'
166166

167167
# Installation variables (Please don't modify!)
168168
DATA_DIR='<should_be_replace_after_installation:DATA_DIR>'
@@ -665,6 +665,14 @@ function _fetch_remote_branches() {
665665
}
666666
}
667667

668+
function _get_file_from_another_branch() {
669+
branch_name=$1
670+
file_path=$2
671+
cd "$ROOT_REPO_DIR" || return 1
672+
git show "$branch_name:./$file_path"
673+
cd "$CUR_DIR" || return 1
674+
}
675+
668676
function _remove_tmp_dir() {
669677
dir_to_remove=$1
670678
[ "$dir_to_remove" != '' ] && rm -rf "/tmp/$dir_to_remove"
@@ -734,8 +742,8 @@ function _load_local_conf_file() {
734742
function _load_remote_conf_file() {
735743
_unset_conf_variables || return 1
736744
branch_name=$1
737-
handling_config_file="origin/$branch_name:./.vuh"
738-
main_branch_config_file=$(git show "$handling_config_file") || {
745+
handling_config_file="origin/$branch_name:.vuh"
746+
main_branch_config_file=$(_get_file_from_another_branch "origin/$branch_name" ".vuh") || {
739747
_show_error_message "Failed to read remote configuration file $handling_config_file!"
740748
return 1
741749
}
@@ -840,6 +848,7 @@ function read_local_version() {
840848

841849
function read_main_version() {
842850
[ "$ARGUMENT_QUIET" = 'false' ] && _show_function_title 'getting main version'
851+
[ "$ARGUMENT_OFFLINE" = 'true' ] || _fetch_remote_branches || exit 1
843852
_load_local_conf_file || exit 1
844853
remote_branch=$MAIN_BRANCH_NAME
845854
if [[ "$SPECIFIED_MAIN_BRANCH" != '' ]]; then
@@ -861,8 +870,8 @@ function read_main_version() {
861870
_load_local_conf_file || exit 1
862871
}
863872
fi
864-
handling_file="origin/$remote_branch:./$VERSION_FILE"
865-
main_branch_file=$(git show "$handling_file") || {
873+
handling_file="origin/$remote_branch:$VERSION_FILE"
874+
main_branch_file=$(_get_file_from_another_branch "origin/$remote_branch" "$VERSION_FILE") || {
866875
_show_error_message "Failed to load file $handling_file"
867876
exit 1
868877
}
@@ -885,7 +894,6 @@ function read_main_version() {
885894
function _get_suggesting_version_using_git() {
886895
read_local_version || exit 1
887896
read_main_version || exit 1
888-
[ "$ARGUMENT_OFFLINE" = 'true' ] || _fetch_remote_branches || exit 1
889897
_load_local_conf_file || exit 1
890898
[ "$ARGUMENT_QUIET" = 'true' ] || _show_function_title 'suggesting relevant version'
891899
largest_version=$(_get_largest_version "$MAIN_VERSION" "$LOCAL_VERSION") || {

0 commit comments

Comments
 (0)