packages
The Louise packages, each released on its own
Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.
Dernier runRéussi#28 · main · 3 min 34 s
0Étoiles
0Forks
3Issues
| 1 | #!/bin/sh |
| 2 | # The packages a change touches, and every package that depends on them, |
| 3 | # one per line: what CI checks and tests on a pull request. |
| 4 | # |
| 5 | # scripts/affected.sh [BASE] (default: origin/main) |
| 6 | # |
| 7 | # A package is a top-level directory holding a louise.toml. Dependencies |
| 8 | # are its path dependencies, dev-dependencies included (`gen`). A change |
| 9 | # outside every package (scripts, workflows, this README) affects them all. |
| 10 | |
| 11 | set -eu |
| 12 | cd "$(dirname "$0")/.." |
| 13 | base="${1:-origin/main}" |
| 14 | |
| 15 | packages() { |
| 16 | for m in */louise.toml; do dirname "$m"; done |
| 17 | } |
| 18 | |
| 19 | # The packages `$1` depends on by path, by their directory names. |
| 20 | deps() { |
| 21 | sed -n 's/.*path *= *"\.\.\/\([A-Za-z0-9_-]*\)".*/\1/p' "$1/louise.toml" |
| 22 | } |
| 23 | |
| 24 | # Committed and uncommitted changes since the branch left `base`, and new |
| 25 | # files. |
| 26 | changed=$( { git diff --name-only "$(git merge-base "$base" HEAD)"; git ls-files --others --exclude-standard; } | sort -u) |
| 27 | if [ -z "$changed" ]; then |
| 28 | exit 0 |
| 29 | fi |
| 30 | all=$(packages) |
| 31 | touched="" |
| 32 | for f in $changed; do |
| 33 | top=${f%%/*} |
| 34 | if [ "$top" = "$f" ] || ! printf '%s\n' "$all" | grep -qx "$top"; then |
| 35 | printf '%s\n' "$all" |
| 36 | exit 0 |
| 37 | fi |
| 38 | touched="$touched $top" |
| 39 | done |
| 40 | |
| 41 | # Close over the reverse dependencies. |
| 42 | selected=$(printf '%s\n' $touched | sort -u) |
| 43 | while :; do |
| 44 | more="$selected" |
| 45 | for p in $all; do |
| 46 | for d in $(deps "$p"); do |
| 47 | if printf '%s\n' "$selected" | grep -qx "$d"; then |
| 48 | more="$more |
| 49 | $p" |
| 50 | fi |
| 51 | done |
| 52 | done |
| 53 | more=$(printf '%s\n' "$more" | sort -u) |
| 54 | [ "$more" = "$selected" ] && break |
| 55 | selected="$more" |
| 56 | done |
| 57 | printf '%s\n' "$selected" |