diff --git a/.update-changes.cfg b/.update-changes.cfg index e3d04b7422..ed23fb4565 100644 --- a/.update-changes.cfg +++ b/.update-changes.cfg @@ -7,15 +7,7 @@ function new_version_hook # test suite repos to check out on a CI system. version=$1 - if [ -d testing/external/zeek-testing ]; then - echo "Updating testing/external/commit-hash.zeek-testing" - ( cd testing/external/zeek-testing && git fetch origin && git rev-parse origin/master ) > testing/external/commit-hash.zeek-testing - git add testing/external/commit-hash.zeek-testing - fi + ./testing/scripts/update-external-repo-pointer.sh testing/external/zeek-testing testing/external/commit-hash.zeek-testing - if [ -d testing/external/zeek-testing-private ]; then - echo "Updating testing/external/commit-hash.zeek-testing-private" - ( cd testing/external/zeek-testing-private && git fetch origin && git rev-parse origin/master ) > testing/external/commit-hash.zeek-testing-private - git add testing/external/commit-hash.zeek-testing-private - fi + ./testing/scripts/update-external-repo-pointer.sh testing/external/zeek-testing-private testing/external/commit-hash.zeek-testing-private } diff --git a/CHANGES b/CHANGES index e0be717f10..43fa7e3ad7 100644 --- a/CHANGES +++ b/CHANGES @@ -1,4 +1,8 @@ +2.6-205 | 2019-04-05 17:06:26 -0700 + + * Add script to update external test repo commit pointers (Jon Siwek, Corelight) + 2.6-203 | 2019-04-04 16:35:52 -0700 * Update DTLS error handling (Johanna Amann, Corelight) diff --git a/VERSION b/VERSION index 92df2bb961..a0c99ee2be 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.6-203 +2.6-205 diff --git a/testing/scripts/update-external-repo-pointer.sh b/testing/scripts/update-external-repo-pointer.sh new file mode 100755 index 0000000000..e6711a0d9d --- /dev/null +++ b/testing/scripts/update-external-repo-pointer.sh @@ -0,0 +1,49 @@ +#! /usr/bin/env bash + +set -e + +if [ $# -ne 2 ]; then + echo "usage: $0 " + exit 1 +fi + +repo_dir=$1 +hash_file=$2 + +repo_base=$(basename $repo_dir) +file_base=$(basename $hash_file) + +if [ ! -d "$repo_dir" ]; then + echo "External repo does not exist: $repo_dir" + exit 1 +fi + +printf "Checking for '$repo_base' changes ..." + +origin_hash=$(cd $repo_dir && git fetch origin && git rev-parse origin/master) +head_hash=$(cd $repo_dir && git rev-parse HEAD) +file_hash=$(cat $hash_file) + +if [ "$file_hash" != "$head_hash" ]; then + printf "\n" + printf "\n" + printf " '$repo_base' pointer has changed:\n" + + line=" $file_base at $file_hash" + len=${#line} + + printf "%${len}s\n" "$line" + printf "%${len}s\n" "origin/master at $origin_hash" + printf "%${len}s\n" "HEAD at $head_hash" + printf "\n" + printf "Update file '$file_base' to HEAD commit ? " + + read -p "[Y/n] " choice + + case "$choice" in + n|N) echo "Skipped '$repo_base'";; + *) echo $head_hash > $hash_file && git add $hash_file && echo "Updated '$file_base'";; + esac +else + echo " none" +fi