diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2021-04-09 18:01:23 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2021-04-09 19:06:27 +0000 |
commit | 68c1980e0ec6a57484a21b2767f7723d934464cf (patch) | |
tree | 7b170681dca107807ba6fa16aa84ed0364cff98c /tcwg-report-orphan-rr-branches.sh | |
parent | 7d9f9a6a92fe5e628cda1b017bf98d3d2c6a0b04 (diff) |
tcwg-report-orphan-rr-branches.sh: Give script a better name
Change-Id: I45a1bd2f0b7c43e0f8803c4db0967330d8945755
Diffstat (limited to 'tcwg-report-orphan-rr-branches.sh')
-rwxr-xr-x | tcwg-report-orphan-rr-branches.sh | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/tcwg-report-orphan-rr-branches.sh b/tcwg-report-orphan-rr-branches.sh new file mode 100755 index 00000000..2522fe46 --- /dev/null +++ b/tcwg-report-orphan-rr-branches.sh @@ -0,0 +1,54 @@ +#!/bin/bash + +set -euf -o pipefail + +# Round-robin CI loops store their baseline state in: +# 1. toolchain/ci/base-artifacts.git repo stores artifacts of +# baseline/reference build in branches named $ci_project/$ci_config. +# 2. toolchain/ci/$project.git repos store sources of $project that match +# baseline/reference build in branches named $ci_project/$ci_config. +# +# Therefore, for a given $ci_project/$ci_config there should be a branch +# in toolchain/ci/base-artifacts.git repo and every relevant $project repo +# toolchain/ci/$project.git . +# +# If there are branches in toolchain/ci/$project.git repos that have +# no match in toolchain/ci/base-artifacts.git repo, then such branches +# are orphans and can be removed. +# +# This script lists such orphan branches. + +scripts=$(dirname "$0") +# shellcheck source=jenkins-helpers.sh +. "$scripts/jenkins-helpers.sh" + +convert_args_to_variables "$@" + +repos+=("${repos[@]-default}") +refs_prefix="${refs_prefix-refs/heads/linaro-local/ci/}" +refs_url="${refs_url-https://git.linaro.org/toolchain/ci/base-artifacts}" +verbose="${verbose-false}" + +if $verbose; then + set -x +fi + +if [ x"${repos[*]}" = x"default" ]; then + repos=(binutils-gdb gcc glibc linux llvm-project newlib qemu) +fi + +branch_list=$(mktemp) +git ls-remote "$refs_url" "${refs_prefix}*" | awk '{ print $2 }' > $branch_list + +for repo in "${repos[@]}"; do + repo_url="$(dirname "$refs_url")/$repo" + while IFS= read -r ref; do + if grep -q "^$ref\$" $branch_list; then + continue + fi + + echo "$repo $ref" + done < <(git ls-remote "$repo_url" "${refs_prefix}*" | awk '{ print $2 }') +done + +rm $branch_list |