fix pusher

This commit is contained in:
Ludwig Nussel
2023-02-23 18:12:04 +01:00
parent f17106dbf4
commit bc02fc7b38
2 changed files with 20 additions and 36 deletions

43
pusher
View File

@@ -2,6 +2,8 @@
set -e
# config options
# shellcheck disable=SC2034
declare -A keep
PR_SRC_USER=
BASE_BRANCH="main"
PR_PROJECT=
@@ -22,7 +24,7 @@ did_push=
tmpfile=$(mktemp pusher.XXXXXX)
cleanup()
{
echo rm -f "$tmpfile"
rm -f "$tmpfile"
}
trap cleanup EXIT
@@ -42,16 +44,6 @@ log_info()
echo "$@"
}
makedict()
{
local dict="$1"
shift
mapfile -t a < <("$@")
for k in "${a[@]}"; do
eval "$dict"["$k"]=1
done
}
request_pulls()
{
curl -s -f "$pr_target?state=open" \
@@ -116,26 +108,17 @@ log_info "to push: ${!pq[*]}"
log_info "remote: ${!rq[*]}"
if [ -n "$show_status" ]; then
if [ -n "${!pq[*]}" ]; then
echo "Push queue:"
for m in "${!pq[@]}"; do
[ "${pq[$m]}" = "${rq[$m]}" ] && continue
echo " ${pq[$m]} $m"
done
fi
if [ -n "${!rq[*]}" ]; then
echo "Request queue:"
for m in "${!rq[@]}"; do
[ "${rq[$m]}" = "${pr[$m]}" ] && continue
echo " ${rq[$m]} $m"
done
fi
if [ -n "${!pr[*]}" ]; then
echo "Requests:"
for m in "${!pr[@]}"; do
echo " ${pr[$m]} $m"
if [ "${#modules[@]}" -eq 0 ]; then
for m in "${!pq[@]}" "${!rq[@]}" "${!pr[@]}"; do
modules["$m"]=1
done
fi
for m in "${!modules[@]}"; do
a=${pq[$m]:0:7}
b=${rq[$m]:0:7}
c=${pr[$m]:0:7}
echo "${a:- } ${b:- } ${c:- } $m"
done
exit 0
fi
@@ -186,7 +169,7 @@ done
if [ -n "$did_push" ]; then
log_info "Updating remote $PUSH_REMOTE"
git remote update "$PUSH_REMOTE" > /dev/null
git remote update -p "$PUSH_REMOTE" > /dev/null
fi
exit "$ret"

View File

@@ -153,6 +153,10 @@ if [ "${#modules[@]}" = 0 ]; then
modules=("${!revs[@]}" "${!new[@]}")
fi
# push queue
declare -A pq
makedict pq git for-each-ref 'refs/pq/*' --format '%(refname)'
# check remotes for updates
declare -A commits
treetext=$(git cat-file -p "$REMOTE/$BASE_BRANCH^{tree}")
@@ -180,13 +184,11 @@ for m in "${modules[@]}"; do
cid=
if ! todrop "$m"; then
set -x
read -r cid _d < <(git ls-remote "$url" "${smbranch:-HEAD}")
if [ -z "$cid" ]; then
echo "$path not in pool" >&2
continue
fi
set +x
fi
# create a new commit for this package
@@ -219,6 +221,9 @@ for m in "${modules[@]}"; do
commits["$m"]="$newcid"
cat "$tmpfile2" > "$tmpfile"
fi
elif [ -n "${pq[refs/pq/$m]}" ]; then
log_info "remove pq for $m"
git update-ref -d "refs/pq/$m"
fi
done
@@ -228,10 +233,6 @@ if [ "$single" = 1 ]; then
commits["all"]="$newcid"
fi
# push queue
declare -A pq
makedict pq git for-each-ref 'refs/pq/*' --format '%(refname)'
for m in "${!commits[@]}"; do
ref="refs/pq/$m"
if [ -n "${pq[$ref]}" ]; then