AkurAI Build
Menu

Public repository / 8b66e18ce8cb51ca3e4124f89fd1429a1d4792f3

AkurAI-Mail / scripts/lint-sibling-deps.sh

Latest change 045c6e9898aee39f49ad8d0e6ca4b5c7697877d2 - OLI-188: roll out lint-config CI job and sibling-dep lint by Ólafur Búi Ólafsson

#!/bin/sh
# Fails when a Cargo.toml path dependency escapes the repo into a sibling that .akurai.yml never checks out.
set -eu
root="$(pwd -P)"
yml="${1:-.akurai.yml}"
status=0
missing="$(find . -name Cargo.toml -not -path '*/target/*' -not -path '*/node_modules/*' | while read -r manifest; do
  dir="$(dirname "$manifest")"
  sed -nE 's/.*path[[:space:]]*=[[:space:]]*"([^"]+)".*/\1/p' "$manifest" | while read -r rel; do
    target="$(realpath -m "$dir/$rel")"
    case "$target" in "$root"|"$root"/*) continue ;; esac
    rest="${target#"$(dirname "$root")"/}"
    echo "${rest%%/*}"
  done
done | sort -u)"
for sibling in $missing; do
  grep -qF "../$sibling" "$yml" 2>/dev/null || { echo "lint-sibling-deps: path dependency on sibling '$sibling' but $yml never checks out ../$sibling" >&2; status=1; }
done
exit "$status"