- Added a comprehensive plan for history rewrites in `docs/plans/history_rewrite.md`, including backup requirements and a checklist for destructive operations. - Created a QA report for history-rewrite scripts in `docs/reports/qa_report.md`, summarizing tests, findings, and recommendations. - Introduced `check_refs.sh` script to list branches and tags, saving a tarball of tag references. - Updated `clean_history.sh` to include non-interactive mode and improved error handling for backup branch pushes. - Enhanced `preview_removals.sh` to support JSON output format and added shallow clone detection. - Added Bats tests for `clean_history.sh` and `validate_after_rewrite.sh` to ensure functionality and error handling. - Implemented pre-commit hook to block commits to `data/backups/` directory. - Improved validation script to check for backup branch existence and run pre-commit checks. - Created temporary test scripts for validating `clean_history.sh` and `validate_after_rewrite.sh` functionality.
43 lines
959 B
Bash
Executable File
43 lines
959 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
IFS=$'\n\t'
|
|
|
|
usage() {
|
|
cat <<EOF
|
|
Usage: $0
|
|
|
|
Lists branches and tags, saves a tag reference tarball to data/backups.
|
|
EOF
|
|
}
|
|
|
|
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
|
usage; exit 0
|
|
fi
|
|
|
|
logdir="data/backups"
|
|
mkdir -p "$logdir"
|
|
ts=$(date +"%Y%m%d-%H%M%S")
|
|
tags_tar="$logdir/tags-$ts.tar.gz"
|
|
|
|
echo "Branches:"
|
|
git branch -a || true
|
|
|
|
echo "Tags:"
|
|
git tag -l || true
|
|
|
|
tmpdir=$(mktemp -d)
|
|
git show-ref --tags > "$tmpdir/tags-show-ref.txt" || true
|
|
tar -C "$tmpdir" -czf "$tags_tar" . || { echo "Warning: failed to create tag tarball" >&2; rm -rf "$tmpdir"; exit 1; }
|
|
rm -rf "$tmpdir"
|
|
echo "Created tags tarball: $tags_tar"
|
|
|
|
echo "Attempting to push tags to origin under refs/backups/tags/*"
|
|
for t in $(git tag --list); do
|
|
if ! git push origin "refs/tags/$t:refs/backups/tags/$t" >/dev/null 2>&1; then
|
|
echo "Warning: pushing tag $t to refs/backups/tags/$t failed" >&2 || true
|
|
fi
|
|
done
|
|
|
|
echo "Done."
|
|
exit 0
|