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>
29 lines
815 B
Bash
29 lines
815 B
Bash
# shellcheck shell=bash
|
|
# shellcheck disable=SC2004,SC2034,SC2154 # shared state and arrays are declared in constants.sh
|
|
# hosts.sh - Names and links of the repositories on each host.
|
|
#
|
|
# Part of create-project.sh: sourced by it, never run on its own.
|
|
#
|
|
# Provides: is_reused, repo_owner, repo_url
|
|
|
|
# is_reused HOST: succeed if the existing repository on HOST will be reused.
|
|
is_reused() {
|
|
[[ ${STATE[reuse_$1]:-0} == 1 ]]
|
|
}
|
|
|
|
repo_owner() {
|
|
if [[ $1 == gitea ]]; then
|
|
printf '%s' "${PROJECT[gitea_owner]}"
|
|
else
|
|
printf '%s' "${PROJECT[github_owner]}"
|
|
fi
|
|
}
|
|
|
|
repo_url() {
|
|
if [[ $1 == gitea ]]; then
|
|
printf '%s/%s/%s' "${CONFIG[GITEA_URL]}" "${PROJECT[gitea_owner]}" "${PROJECT[name]}"
|
|
else
|
|
printf '%s/%s/%s' "${CONFIG[GITHUB_WEB_URL]}" "${PROJECT[github_owner]}" "${PROJECT[name]}"
|
|
fi
|
|
}
|