mirror of
https://github.com/valitydev/holmes.git
synced 2024-11-06 01:45:25 +00:00
4cdec0411f
* Switch proto upstreams to valitydev: valitydev/bender-proto@38ce3ff valitydev/binbase-proto@9db92d9 valitydev/cds-proto@ed9f907 valitydev/damsel@d384c12 valitydev/fistful-proto@c45166d valitydev/limiter-proto@8c08550 valitydev/machinegun-proto@af57ba1 valitydev/msgpack-proto@8742c7a * Rewrite Dockerfile * Include protocols as full-fledged git repos * Add GH Actions CI workflow
44 lines
1.1 KiB
Bash
Executable File
44 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
PROTO_MODULE_RE='(damsel|[a-z]+-proto)'
|
|
GIT_OPTIONS='-c advice.detachedHead=false -c init.defaultBranch=master'
|
|
|
|
TARGET_DIR="$1"
|
|
[ -z "$TARGET_DIR" ] && {
|
|
echo "usage: $0 <target-dir>"
|
|
exit -1
|
|
}
|
|
|
|
function enumerate_proto_modules {
|
|
git ls-files --error-unmatch --stage \
|
|
| grep '^160000' \
|
|
| awk '{ print $4 " " $2; }' \
|
|
| grep -E "$PROTO_MODULE_RE"
|
|
}
|
|
|
|
function emit_clone_command {
|
|
local name="$1"
|
|
local sha1="$2"
|
|
local branch="$(git config -f .gitmodules --get "submodule.${name}.branch")"
|
|
local url="$(git config -f .gitmodules --get "submodule.${name}.url")"
|
|
local target="${TARGET_DIR}/${name}"
|
|
local git="git ${GIT_OPTIONS} -C ${target}"
|
|
|
|
mkdir -p "${target}"
|
|
$git init
|
|
$git remote add origin "${url}"
|
|
$git fetch origin "${sha1}"
|
|
if [ -n "${branch}" ]; then
|
|
$git fetch origin "${branch}"
|
|
$git checkout -B "${branch}" "${sha1}"
|
|
$git branch --set-upstream-to "origin/${branch}"
|
|
else
|
|
$git checkout "${sha1}"
|
|
fi
|
|
|
|
}
|
|
|
|
enumerate_proto_modules | while read name sha1; do
|
|
emit_clone_command $name $sha1
|
|
done
|