diff options
author | Joseph Herlant <aerostitch@debian.org> | 2019-11-02 03:43:06 -0700 |
---|---|---|
committer | Joseph Herlant <aerostitch@debian.org> | 2019-11-02 03:43:06 -0700 |
commit | 852e0e65f52e4e6251a49282b1039b89bb8a77ab (patch) | |
tree | 1651ecb3fe74b0044cdcb2b1d867bcf500219adc | |
parent | 4d032ffe4d5e40ffd3b7e35dc6951eab9f8c2b86 (diff) | |
download | navit-852e0e65f52e4e6251a49282b1039b89bb8a77ab.tar.gz |
local -n is not supported everywhere
-rwxr-xr-x | scripts/check_need_build.sh | 55 |
1 files changed, 20 insertions, 35 deletions
diff --git a/scripts/check_need_build.sh b/scripts/check_need_build.sh index 5f650a2cd..4e15adeb7 100755 --- a/scripts/check_need_build.sh +++ b/scripts/check_need_build.sh @@ -4,43 +4,28 @@ # The idea is also to build if the exit code is different from 0 as it means we cannot get a filtered list properly. # # ################################################################################################################### # -# @brief: constructs the list of files that differ from the trunk branch. -# Note that if you are on the trunk or master branch it will return the files modified by the last commit. -# @param: a variable you want to use to get the resulting value -# @return: nothing (the input variable is modified according to the brief description) -list_files_git_diff(){ - local -n files=$1 - files=$(git diff --name-only refs/remotes/origin/trunk) +# This blockconstructs the list of files that differ from the trunk branch. +# Note that if you are on the trunk or master branch it will return the files modified by the last commit. +declare -a file_list=$(git diff --name-only refs/remotes/origin/trunk) - # If there is no diff that might just mean that you are on the trunk or master branch - # so you just want to check the last commit. This way we still have that check more - # or less working when pushing directly to trunk or when merging in master. - if [[ -z "$files" ]]; then - files=$(git diff --name-only HEAD^) - fi -} +# If there is no diff that might just mean that you are on the trunk or master branch +# so you just want to check the last commit. This way we still have that check more +# or less working when pushing directly to trunk or when merging in master. +if [[ -z "$files" ]]; then + file_list=$(git diff --name-only HEAD^) +fi -# @brief: get the list of files that have differed from trunk (by calling list_files_git_diff for the full list) -# and filters out those don't match the pattern we use to exclude files that should not trigger a build. -# @param: a variable you want to use to get the resulting value -# @return: nothing (the input variable is modified according to the brief description) -filtered_files_git_diff(){ - local -n _ret=$1 - declare -a filters=('^docs/.*' '.*\.md$' '.*\.rst$' '.*') # WARNING! '.*' is here only for testing if the circleci command works. It should be removed before merge! - declare -a file_list=() - list_files_git_diff file_list - for f in ${file_list[@]}; do - for filter in "${filters[@]}" ; do - if [[ "$f" =~ $filter ]]; then - # This removes the element from the element matching the filter - file_list=(${file_list[@]/$f}) - break - fi - done +# This block filters out those don't match the pattern we use to exclude files that should not trigger a build. +declare -a filters=('^docs/.*' '.*\.md$' '.*\.rst$' '.*') # WARNING! '.*' is here only for testing if the circleci command works. It should be removed before merge! +for f in ${file_list[@]}; do + for filter in "${filters[@]}" ; do + if [[ "$f" =~ $filter ]]; then + # This removes the element from the element matching the filter + file_list=(${file_list[@]/$f}) + break + fi done - _ret=$file_list -} +done -filtered_files_git_diff filtered_out_modified_files # exits with a 0 if the list is empty -[[ -z "${filtered_out_modified_files}" ]] +[[ -z "${filte_list}" ]] |