88# - Compares committed content only: the vendor/interchange tree at HEAD
99# against the stock commit's tree, by exact path, mode and blob id. Local
1010# untracked or uncommitted files are not seen.
11- # - The vendored tree is a pruned checkout (upstream-only paths such as
12- # bin/, docs/, or packages never vendored are reported as information,
13- # not failures). The gate fails on any other difference: a changed blob,
14- # mode or type, or a path added locally, unless the path is exactly an
15- # allowlist entry. Our provenance record (VENDORED.md) is excluded.
11+ # - The vendored tree is a pruned checkout: a stock path missing from it is
12+ # reported as information when tooling/vendor-diff-pruned.txt lists it or
13+ # a directory above it, and fails otherwise. The gate fails on any other
14+ # difference: a changed blob, mode or type, or a path added locally, unless
15+ # the path is exactly an allowlist entry. Our provenance record
16+ # (VENDORED.md) is excluded.
1617#
1718# Env overrides:
1819# INTERCHANGE_STOCK_REPO upstream repo (default https://github.com/faremeter/interchange)
@@ -22,6 +23,7 @@ set -eu
2223STOCK_REPO=" ${INTERCHANGE_STOCK_REPO:- https:// github.com/ faremeter/ interchange} "
2324STOCK_REF=" ${INTERCHANGE_STOCK_REF:- b1ca01f0d9bc2eb203e95b1780a6f685c5da8215} "
2425ALLOWLIST=" tooling/vendor-diff-allowlist.txt"
26+ PRUNED=" tooling/vendor-diff-pruned.txt"
2527VENDOR_DIR=" vendor/interchange"
2628
2729WORK=" $( mktemp -d) "
@@ -44,27 +46,36 @@ git -C "$WORK/stock" -c core.quotePath=true diff-tree -r --no-renames --no-abbre
4446 " $STOCK_TREE " " $VENDOR_TREE " > " $WORK /diff.txt"
4547
4648grep -v ' ^#' " $ALLOWLIST " | grep -v ' ^$' > " $WORK /allowlist.txt" || true
49+ grep -v ' ^#' " $PRUNED " | grep -v ' ^$' > " $WORK /pruned.txt" || true
4750
48- # Deleted entries are the pruned upstream-only paths. Every other entry fails
49- # unless its path is exactly allowlisted; a line that is not a diff-tree raw
50- # entry fails as it is.
51+ # A deleted entry passes as pruned when its path or a directory above it is
52+ # listed. Every other entry fails unless its path is exactly allowlisted; a
53+ # line that is not a diff-tree raw entry fails as it is.
5154awk -v allowlist=" $WORK /allowlist.txt" \
55+ -v pruned=" $WORK /pruned.txt" \
5256 -v unexpected=" $WORK /unexpected.txt" \
5357 -v upstream_only=" $WORK /upstream-only.txt" '
5458 BEGIN {
5559 while ((getline entry < allowlist) > 0) allowed[entry] = 1
5660 allowed["VENDORED.md"] = 1
61+ while ((getline entry < pruned) > 0) pruned_paths[entry] = 1
5762 printf "" > unexpected
5863 printf "" > upstream_only
5964 }
65+ function is_pruned(path, i) {
66+ if (path in pruned_paths) return 1
67+ for (i = length(path) - 1; i > 0; i--)
68+ if (substr(path, i, 1) == "/" && (substr(path, 1, i) in pruned_paths)) return 1
69+ return 0
70+ }
6071 !/^:[0-7]+ [0-7]+ [0-9a-f]+ [0-9a-f]+ [A-Z][0-9]*\t/ {
6172 print "unparseable: " $0 > unexpected
6273 next
6374 }
6475 {
6576 path = substr($0, index($0, "\t") + 1)
6677 status = substr($5, 1, 1)
67- if (status == "D") print path > upstream_only
78+ if (status == "D" && is_pruned(path) ) print path > upstream_only
6879 else if (!(path in allowed)) print status " " path > unexpected
6980 }
7081' " $WORK /diff.txt"
0 commit comments