Add ? prefix for sample files in file-list; fix bootstrap/upgrade
bootstrap.sh wrote .diachron-version to the temp clone directory instead of the target project, causing upgrade.sh to fail. Fix that and teach all three scripts (bootstrap, upgrade, diff-upstream) about the new ? prefix convention in file-list. Sample files (?-prefixed) are copied on bootstrap but left alone on upgrade so user modifications are preserved. New samples introduced in a newer framework version are still copied if absent. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
50
upgrade.sh
50
upgrade.sh
@@ -62,11 +62,17 @@ echo "Upgrading: $old_ref -> $new_ref"
|
||||
echo ""
|
||||
|
||||
# Read current file-list (files to remove)
|
||||
# Entries prefixed with ? are sample files -- we don't remove those on upgrade.
|
||||
old_files=()
|
||||
old_samples=()
|
||||
while IFS= read -r line; do
|
||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
||||
[[ -z "$line" ]] && continue
|
||||
old_files+=("$line")
|
||||
if [[ "$line" == \?* ]]; then
|
||||
old_samples+=("${line#\?}")
|
||||
else
|
||||
old_files+=("$line")
|
||||
fi
|
||||
done < "$DIR/file-list"
|
||||
|
||||
# Clone and checkout new version into a temp directory
|
||||
@@ -76,25 +82,44 @@ git -C "$tmpdir/diachron" checkout --quiet "$new_ref"
|
||||
|
||||
# Read new file-list (files to add)
|
||||
new_files=()
|
||||
new_samples=()
|
||||
while IFS= read -r line; do
|
||||
[[ "$line" =~ ^[[:space:]]*# ]] && continue
|
||||
[[ -z "$line" ]] && continue
|
||||
new_files+=("$line")
|
||||
if [[ "$line" == \?* ]]; then
|
||||
new_samples+=("${line#\?}")
|
||||
else
|
||||
new_files+=("$line")
|
||||
fi
|
||||
done < "$tmpdir/diachron/file-list"
|
||||
|
||||
# Remove old framework files
|
||||
# Remove old framework files (not samples -- those belong to the user)
|
||||
for f in "${old_files[@]}"; do
|
||||
git -C "$DIR" rm -rf --quiet --ignore-unmatch "$f"
|
||||
done
|
||||
|
||||
# Copy in new framework files
|
||||
(cd "$tmpdir/diachron" && tar cvf - "${new_files[@]}") | (cd "$DIR" && tar xf -)
|
||||
(cd "$tmpdir/diachron" && tar cf - "${new_files[@]}") | (cd "$DIR" && tar xf -)
|
||||
|
||||
# Stage them
|
||||
for f in "${new_files[@]}"; do
|
||||
git -C "$DIR" add "$f"
|
||||
done
|
||||
|
||||
# Handle sample files: copy only if the user doesn't already have them
|
||||
samples_added=()
|
||||
samples_skipped=()
|
||||
for f in "${new_samples[@]}"; do
|
||||
if [ -e "$DIR/$f" ]; then
|
||||
samples_skipped+=("$f")
|
||||
else
|
||||
# New sample that doesn't exist yet -- copy it in
|
||||
(cd "$tmpdir/diachron" && tar cf - "$f") | (cd "$DIR" && tar xf -)
|
||||
git -C "$DIR" add "$f"
|
||||
samples_added+=("$f")
|
||||
fi
|
||||
done
|
||||
|
||||
# Update version marker
|
||||
echo "$new_ref" > "$DIR/.diachron-version"
|
||||
git -C "$DIR" add "$DIR/.diachron-version"
|
||||
@@ -102,6 +127,23 @@ git -C "$DIR" add "$DIR/.diachron-version"
|
||||
echo "=== Upgrade staged: $old_ref -> $new_ref ==="
|
||||
echo ""
|
||||
echo "Framework files have been removed, replaced, and staged."
|
||||
|
||||
if [ ${#samples_added[@]} -gt 0 ]; then
|
||||
echo ""
|
||||
echo "New sample files added:"
|
||||
for f in "${samples_added[@]}"; do
|
||||
echo " + $f"
|
||||
done
|
||||
fi
|
||||
|
||||
if [ ${#samples_skipped[@]} -gt 0 ]; then
|
||||
echo ""
|
||||
echo "Sample files skipped (you already have these):"
|
||||
for f in "${samples_skipped[@]}"; do
|
||||
echo " ~ $f"
|
||||
done
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Next steps:"
|
||||
echo " 1. Review: git diff --cached"
|
||||
|
||||
Reference in New Issue
Block a user