Repositories / ocaml-git.git

scripts/create-demo-fixture.sh

Clone (read-only): git clone http://git.guha-anderson.com/git/ocaml-git.git

Branch
1497 bytes · 3aa0c94d184d
#!/usr/bin/env bash set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" WORK="$ROOT/.build/fixture-work" REPO="$WORK/demo-repo" OUT="$ROOT/fixtures/demo-repo.tar.gz" rm -rf "$WORK" mkdir -p "$REPO" "$ROOT/fixtures" git -C "$REPO" init -b main >/dev/null git -C "$REPO" config user.name "Fixture Author" git -C "$REPO" config user.email "fixture@example.com" cat > "$REPO/README.md" <<'TXT' # Demo repository This repository is a deterministic fixture for ocaml-git tests. TXT mkdir -p "$REPO/src" cat > "$REPO/src/hello.txt" <<'TXT' hello TXT git -C "$REPO" add README.md src/hello.txt GIT_AUTHOR_DATE="2024-01-02T03:04:05Z" \ GIT_COMMITTER_DATE="2024-01-02T03:04:05Z" \ git -C "$REPO" commit -m "Initial fixture commit" >/dev/null git -C "$REPO" checkout -b feature/demo >/dev/null cat > "$REPO/src/feature.txt" <<'TXT' feature TXT git -C "$REPO" add src/feature.txt GIT_AUTHOR_DATE="2024-01-03T03:04:05Z" \ GIT_COMMITTER_DATE="2024-01-03T03:04:05Z" \ git -C "$REPO" commit -m "Add feature file" >/dev/null git -C "$REPO" checkout main >/dev/null cat >> "$REPO/README.md" <<'TXT' Second line. TXT git -C "$REPO" add README.md GIT_AUTHOR_DATE="2024-01-04T03:04:05Z" \ GIT_COMMITTER_DATE="2024-01-04T03:04:05Z" \ git -C "$REPO" commit -m "Update readme" >/dev/null git -C "$REPO" tag v1.0 git -C "$REPO" checkout main >/dev/null tar --sort=name --mtime="2024-01-05 00:00Z" --owner=0 --group=0 --numeric-owner \ -C "$WORK" -czf "$OUT" demo-repo echo "$OUT"