#!/bin/bash set -e # Check if no argument is provided if [ $# -eq 0 ]; then echo "Usage: $0 " exit 1 fi directory=$1 # Check if the directory exists if [ ! -d "$directory" ]; then echo "Directory '$directory' not found." exit 1 fi # Check if the directory is a Git repository if [ ! -d "$directory/.git" ]; then echo "Directory '$directory' is not a Git repository." exit 1 fi echo "Directory '$directory' is a Git repository." tmpdir=$(mktemp -d) pushd "$tmpdir" trap 'rm -rf $tmpdir' EXIT git clone "${directory}" test-repo cd test-repo git fetch origin refs/notes/perf-v2:refs/notes/perf-v2 git checkout refs/notes/perf-v2 process_file() { if grep '"|'"'" "$1"; then echo "Detected quotes in input, file: $1" exit 1 fi tr " " "" < "$1" > tmpfile && mv tmpfile "$1" git add "$1" } git ls-tree -r --name-only HEAD | while read -r file; do if [ ! -d "$file" ]; then process_file "$file" fi done git commit -m 'migrate to v3' git push origin HEAD:refs/notes/perf-v3