#!/usr/bin/env bash
# التمرين 15.1: ضع مجلد الكتاب تحت Git واصنع أول إيداع. شغّل: bash first-commit.sh
# يعمل في نسخة مؤقتة، فيها ملفات قليلة مكان الفصول 1 إلى 14.
set -e
export GIT_AUTHOR_NAME="سارة خان" GIT_AUTHOR_EMAIL="sara@example.com"
export GIT_COMMITTER_NAME="$GIT_AUTHOR_NAME" GIT_COMMITTER_EMAIL="$GIT_AUTHOR_EMAIL"
export GIT_CONFIG_GLOBAL=/dev/null  # تجاهل إعدادات Git الخاصة بك أثناء تشغيل السكربت
run() { local s="\$"; for a in "$@"; do if [[ $a == *" "* ]]; then s+=" \"$a\""; else s+=" $a"; fi; done; echo "$s"; "$@"; }
cd "$(mktemp -d)"
mkdir -p code-from-zero/chapter-01 code-from-zero/chapter-05
echo 'console.log("Hello, world!");' > code-from-zero/chapter-01/hello.js
echo '<h1>Sara</h1>' > code-from-zero/chapter-05/profile.html
cd code-from-zero

run git init -q -b main
run git status --short
run git add .
run git commit -q -m "Add everything from chapters 1 to 14"
run git log --oneline --stat
