File size: 696 Bytes
a4edccc | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/env bash
set -euo pipefail
repo=${1:-$PWD}
out=${LOLBENCH_PATCH_OUT:-/logs/artifacts/solution.patch}
mkdir -p "$(dirname "$out")"
cd "$repo"
baseline=/opt/lolbench/base_untracked.txt
current=$(mktemp)
new_files=$(mktemp)
trap 'rm -f "$current" "$new_files"' EXIT
git ls-files --others --exclude-standard | sort > "$current"
if [ -f "$baseline" ]; then
comm -13 "$baseline" "$current" > "$new_files"
else
cp "$current" "$new_files"
fi
if [ -s "$new_files" ]; then
xargs -r git add -N -- < "$new_files"
fi
git diff --binary > "$out"
if [ ! -s "$out" ]; then
echo "warning: wrote an empty solution patch to $out" >&2
else
echo "wrote solution patch to $out"
fi
|