Add the GitHub and Gitea steps and split the script into library files

Dry run by default: the script reads from both hosts (tokens, owners,
names, license, SSH) and prints a plan; --apply creates the repositories
and the Gitea -> GitHub push mirror after a final yes. Choosing GitHub
applies the AGPL-3.0 license to the Gitea repository. A failed step is
reported with what exists and how to continue; nothing is ever deleted.

create-project.sh is now the entry point; the work lives in src/lib/, one
responsibility per file. .gitignore gets !src/lib (the Python template
ignores any lib/ folder). Tests grow to 599 checks, with a stub curl and
ssh, and guards for the file structure.

Task: MIL-002#1
Task: MIL-002#2
Task: MIL-002#3
Task: MIL-002#4
Task: MIL-002#5
Task: MIL-002#6
Refs #9
Refs #10
Refs #11
Refs #12
Refs #13
Refs #14

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-05 15:29:10 +08:00
co-authored by Claude Sonnet 5.5
parent 903c948d85
commit 736cdb42fc
30 changed files with 2269 additions and 668 deletions
+39
View File
@@ -0,0 +1,39 @@
# shellcheck shell=bash
# shellcheck disable=SC2004,SC2034,SC2154 # shared state and arrays are declared in constants.sh
# plan.sh - Printing what the script is about to do.
#
# Part of create-project.sh: sourced by it, never run on its own.
#
# Provides: print_plan
print_plan() {
local gitea_action github_action origin_note
say ""
say "Plan:"
if ((STATE[reuse_gitea])); then
gitea_action="reuse the existing repository (you will be asked to confirm)"
elif ((PROJECT[has_github])); then
gitea_action="create (${PROJECT[visibility]}) with the $AGPL_LICENSE_KEY license"
else
gitea_action="create (${PROJECT[visibility]}), empty"
fi
say "$(printf ' %-18s: %s %s' "Gitea repository" "$gitea_action" "$(repo_url gitea)")"
if ((PROJECT[has_github])); then
if ((STATE[reuse_github])); then
github_action="reuse the existing empty repository (you will be asked to confirm)"
else
github_action="create (${PROJECT[visibility]}), empty"
fi
say "$(printf ' %-18s: %s %s' "GitHub repository" "$github_action" "$(repo_url github)")"
say "$(printf ' %-18s: %s' "Push mirror" "Gitea -> GitHub every ${CONFIG[MIRROR_INTERVAL]}")"
else
say "$(printf ' %-18s: %s' "GitHub repository" "not used")"
say "$(printf ' %-18s: %s' "Push mirror" "not used")"
fi
if ((STATE[is_ssh_ok])); then
origin_note="SSH (the SSH test passed)"
else
origin_note="HTTPS (SSH test: ${STATE[ssh_note]})"
fi
say "$(printf ' %-18s: %s' "Local origin" "will use $origin_note, in a later phase")"
}