File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -53,9 +53,7 @@ check_git_match() {
5353 local target_ref=" $1 "
5454 local repo_dir=" ${2:- .} "
5555
56- # Save current directory and move to repo
57- local oldpwd=" $PWD "
58- cd " $repo_dir " || return 2
56+ pushd " $repo_dir " > /dev/null || return 2
5957
6058 local current_tag current_branch current_commit_long current_commit_short
6159 current_tag=$( git describe --tags --exact-match 2> /dev/null || true)
@@ -65,25 +63,25 @@ check_git_match() {
6563
6664 if [[ -n " $current_tag " && " $target_ref " == " $current_tag " ]]; then
6765 echo " match: tag ($current_tag )"
68- cd " $oldpwd "
66+ popd > /dev/null
6967 return 0
7068 elif [[ -n " $current_branch " && " $target_ref " == " $current_branch " ]]; then
7169 echo " match: branch ($current_branch )"
72- cd " $oldpwd "
70+ popd > /dev/null
7371 return 0
7472 elif [[ -n " $current_commit_long " && " $target_ref " == " $current_commit_long " ]]; then
7573 echo " match: commit (long $current_commit_long )"
76- cd " $oldpwd "
74+ popd > /dev/null
7775 return 0
7876 elif [[ -n " $current_commit_short " && " $target_ref " == " $current_commit_short " ]]; then
7977 echo " match: commit (short $current_commit_short )"
80- cd " $oldpwd "
78+ popd > /dev/null
8179 return 0
8280 else
8381 echo " no match found for $target_ref "
8482 printf " Version inconsistency. Please fix ${repo_dir} \n"
8583 printf " (expected: ${target_ref} , got: ${current_tag} ${current_branch} ${current_commit_long} ${current_commit_short} )\n"
86- cd " $oldpwd "
84+ popd > /dev/null
8785 exit 1
8886 fi
8987}
You can’t perform that action at this time.
0 commit comments