38 lines
1.1 KiB
Bash
38 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
# init_repo.sh
|
|
# Initialises the local git repo, sets up branch structure, and pushes to Forgejo.
|
|
#
|
|
# Usage:
|
|
# chmod +x tools/init_repo.sh
|
|
# FORGEJO_URL=https://your-forgejo.example.com \
|
|
# FORGEJO_USER=yourname \
|
|
# FORGEJO_REPO=squadron-td \
|
|
# bash tools/init_repo.sh
|
|
|
|
set -e
|
|
|
|
FORGEJO_URL="${FORGEJO_URL:?Set FORGEJO_URL}"
|
|
FORGEJO_USER="${FORGEJO_USER:?Set FORGEJO_USER}"
|
|
FORGEJO_REPO="${FORGEJO_REPO:?Set FORGEJO_REPO}"
|
|
REMOTE="$FORGEJO_URL/$FORGEJO_USER/$FORGEJO_REPO.git"
|
|
|
|
echo "==> Initialising git repo"
|
|
git init
|
|
git add .
|
|
git commit -m "chore: initial scaffold"
|
|
|
|
echo "==> Creating and pushing main branch"
|
|
git branch -M main
|
|
git remote add origin "$REMOTE" 2>/dev/null || git remote set-url origin "$REMOTE"
|
|
git push -u origin main
|
|
|
|
echo "==> Creating develop branch"
|
|
git checkout -b develop
|
|
git push -u origin develop
|
|
|
|
echo ""
|
|
echo "Done. Now run:"
|
|
echo " python3 tools/forgejo_setup.py --url $FORGEJO_URL --token TOKEN --owner $FORGEJO_USER --repo $FORGEJO_REPO"
|
|
echo ""
|
|
echo "Then configure branch protection in:"
|
|
echo " $FORGEJO_URL/$FORGEJO_USER/$FORGEJO_REPO/settings/branches"
|