#!/usr/bin/env bash # List the files that go into the installed plugin: everything git tracks, # minus the patterns in .distignore. # # Deliberately the only answer to "what ships". The release zip and the # hygiene checks both read it, so a file cannot be excluded from one and # included in the other — which is the version of this bug that ends with # internal notes readable over HTTP on a live shop. set -euo pipefail cd "$(dirname "$0")/.." [ -f .distignore ] || { echo ".distignore is missing — the zip would contain git files and internal notes." >&2; exit 1; } patterns=() while IFS= read -r line; do line="${line%%#*}" line="$(printf '%s' "$line" | sed -E 's/^[[:space:]]+|[[:space:]]+$//g')" [ -n "$line" ] && patterns+=("${line%/}") done < .distignore git ls-files | while IFS= read -r file; do keep=1 for p in "${patterns[@]}"; do # A bare name excludes the file or directory wherever it appears, which is # how .distignore is read everywhere else. Anchor with a leading / to mean # the repo root only. case "$p" in /*) case "$file" in "${p#/}"|"${p#/}"/*) keep=0 ;; esac ;; *) case "$file" in $p|$p/*|*/$p|*/$p/*) keep=0 ;; esac ;; esac [ "$keep" = 0 ] && break done [ "$keep" = 1 ] && printf '%s\n' "$file" done