Files
RepoFoundry/src/lib/util.sh
T
TirsvadandClaude Sonnet 5.5 736cdb42fc 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>
2026-10-05 15:29:10 +08:00

35 lines
789 B
Bash

# shellcheck shell=bash
# shellcheck disable=SC2004,SC2034,SC2154 # shared state and arrays are declared in constants.sh
# util.sh - Small string and list helpers with no knowledge of the project.
#
# Part of create-project.sh: sourced by it, never run on its own.
#
# Provides: trim, in_list, has_control_character, is_same_name
trim() {
local text="$1"
text="${text#"${text%%[![:space:]]*}"}"
text="${text%"${text##*[![:space:]]}"}"
printf '%s' "$text"
}
# in_list NEEDLE ITEM...: succeed if NEEDLE equals one of the items.
in_list() {
local needle="$1" item
shift
for item in "$@"; do
if [[ $item == "$needle" ]]; then
return 0
fi
done
return 1
}
has_control_character() {
[[ $1 == *[[:cntrl:]]* ]]
}
is_same_name() {
[[ ${1,,} == "${2,,}" ]]
}