From bc02fc7b3816a83164b69a0e45e75058706a3955 Mon Sep 17 00:00:00 2001 From: Ludwig Nussel Date: Thu, 23 Feb 2023 18:12:04 +0100 Subject: [PATCH] fix pusher --- pusher | 43 +++++++++++++------------------------------ updatemodules | 13 +++++++------ 2 files changed, 20 insertions(+), 36 deletions(-) diff --git a/pusher b/pusher index c86df16..57809be 100755 --- a/pusher +++ b/pusher @@ -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" diff --git a/updatemodules b/updatemodules index 200e424..adf0085 100755 --- a/updatemodules +++ b/updatemodules @@ -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