#!/bin/bash set -euf -o pipefail scripts=$(dirname "$0") # shellcheck source=jenkins-helpers.sh . "$scripts/jenkins-helpers.sh" convert_args_to_variables "$@" days="${days-10}" human="${human-true}" refs_prefix="${refs_prefix-refs/heads/linaro-local/ci/}" refs_url_prefix="${refs_url_prefix-https://git.linaro.org/toolchain/ci}" repos=("${repos[@]-default}") verbose="${verbose-false}" if $verbose; then set -x fi if [ x"${repos[*]}" = x"default" ]; then repos=(base-artifacts binutils-gdb gcc glibc linux llvm-project newlib qemu) fi process_git_url () { ( set -euf -o pipefail local refs_url="$1" # Initialize base-artifacts repo (by cloning its "empty" branch). refs_repo=$(basename "$refs_url" .git) clone_or_update_repo_no_checkout "$refs_repo" "$refs_url" auto empty origin \ >/dev/null 2>&1 git -C "$refs_repo" reset --hard >/dev/null 2>&1 # Walk through all commits of all tcwg_bmk* branches and mark results # referenced in those results with "used_by" file. while IFS= read -r ref; do dst_ref="refs/remotes/origin/${ref#refs/heads/}" git -C "$refs_repo" fetch -q origin "+$ref:$dst_ref" >/dev/null 2>&1 commit_stamp=$(git -C "$refs_repo" show --no-patch --pretty=%ct "$dst_ref") days_ago=$((($(date +%s) - $commit_stamp) / (24 * 3600))) if [ $days_ago -gt $days ]; then if $human; then echo "$refs_repo: ${ref#$refs_prefix}: last updated $days_ago days ago" else echo "$refs_repo:$ref" fi fi done < <(git ls-remote "$refs_url" "${refs_prefix}*" | awk '{ print $2 }') ) } for repo in "${repos[@]}"; do process_git_url "$refs_url_prefix/$repo" & done | sort wait