zeek/testing/external/scripts/sync-repo
Christian Kreibich bf9b1ebbbe Add helpers for syncing commit files with external testsuites
This provides "make sync-repos" to check out all locally available testsuites at
the commits indicated in their commit files, and "make sync-commits" to update
the commit files to the HEADs of the local testsuite repos.

Also adds the commit -> repo sync for the Makefile init target so initialization
always lands on the right version, and removes the corresponding explicit
checkout from the CI repo setup.
2022-06-28 13:20:14 -07:00

23 lines
585 B
Bash
Executable file

#! /usr/bin/env bash
#
# This moves the requested test repo to the commit indicated in its commit file.
# If repo or commit file do not exist, it does nothing.
[[ -z "$1" ]] && {
echo "sync-repo needs a local testsuite repository path as argument"
exit 1
}
repo="$1"
reponame=$(basename $repo)
commitfile=commit-hash.$reponame
[[ ! -d $repo || ! -f $commitfile ]] && exit 0
commit=$(cat $commitfile)
[[ $commit == $(cd $repo && git rev-parse HEAD) ]] && exit 0
(
echo "Moving '$reponame' to $commit"
cd $repo && git -c advice.detachedHead=false checkout $commit
)