#!/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