SPB Git

Repository Public License

setup.sh 2.7 KB 64 lines shellscript

1#!/usr/bin/env bash2# ORIX OS Automation3# File: Workflows/Samples/git-test-and-review/setup.sh4# Description: Creates the tiny sample Git repository of the "Git repository test-and-review assistant" example: two commits, then an uncommitted change that breaks one test.5#6# Author: Simon-Pierre Boucher7# Contact: contact@spboucher.ai8#9# Usage: ./setup.sh [target folder]      (default: ~/ORIX Samples/git-test-and-review)10# Creates <target>/repo. Refuses to touch an existing repo folder. No nested .git is stored in the ORIX repository:11# the sample repository only exists after this script ran.12set -euo pipefail13TARGET="${1:-$HOME/ORIX Samples/git-test-and-review}"14REPO="$TARGET/repo"15[ -e "$REPO" ] && { echo "setup: $REPO already exists; remove it first" >&2; exit 1; }16mkdir -p "$REPO"17cd "$REPO"18export GIT_CONFIG_GLOBAL=/dev/null GIT_CONFIG_SYSTEM=/dev/null19git init -q -b main .20git config user.name "ORIX Sample"21git config user.email "sample@example.invalid"22git config commit.gpgsign false23export GIT_AUTHOR_DATE="2026-11-02T09:00:00Z" GIT_COMMITTER_DATE="2026-11-02T09:00:00Z"2425cat > slugify.sh <<'SH'26#!/bin/sh27# slugify: lower-case words joined by dashes.28#   sh slugify.sh "Hello World"   ->   hello-world29printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | tr -s ' ' '-'30printf '\n'31SH32cat > run-tests.sh <<'SH'33#!/bin/sh34# Tiny test runner: prints one line per case and exits 1 when any case fails. Reads only; writes nothing.35failed=036check() {37  got="$(sh slugify.sh "$1")"38  if [ "$got" = "$2" ]; then echo "ok   - slugify '$1' -> '$got'"; else echo "FAIL - slugify '$1': expected '$2', got '$got'"; failed=1; fi39}40check "Hello World" "hello-world"41check "ORIX OS Automation" "orix-os-automation"42check "two  spaces" "two-spaces"43if [ "$failed" -eq 0 ]; then echo "3 tests passed"; else echo "tests FAILED"; fi44exit "$failed"45SH46printf '# slugify\n\nA one-line shell helper with a tiny test runner (`sh run-tests.sh`).\n' > README.md47git add -A && git commit -q -m "Add slugify helper and its tests"4849export GIT_AUTHOR_DATE="2026-11-09T09:00:00Z" GIT_COMMITTER_DATE="2026-11-09T09:00:00Z"50printf '\nUsage: `sh slugify.sh "Some Title"`.\n' >> README.md51git add -A && git commit -q -m "Document the usage"5253# The uncommitted change under review: underscores instead of dashes (breaks all three tests) and a README note.54cat > slugify.sh <<'SH'55#!/bin/sh56# slugify: lower-case words joined by underscores.57#   sh slugify.sh "Hello World"   ->   hello_world58printf '%s' "$1" | tr '[:upper:]' '[:lower:]' | tr -s ' ' '_'59printf '\n'60SH61printf '\nSeparator changed to an underscore.\n' >> README.md62printf 'scratch file, not tracked\n' > notes.tmp63echo "setup: created $REPO (2 commits on main, 2 modified files, 1 untracked file)"64
Files main
Menu

Theme