Fixes #778 ## Changes Add git identity warning to preflight_check() (warns if user.name/user.email missing) and auto-configure repo-local identity in setup_ops_repo() before the seed commit. This prevents init from failing late when git identity is not configured globally. Co-authored-by: openhands <openhands@all-hands.dev> Reviewed-on: https://codeberg.org/johba/disinto/pulls/780 Reviewed-by: Disinto_bot <disinto_bot@noreply.codeberg.org>
This commit is contained in:
parent
f918e26cce
commit
4251f9fb0e
2 changed files with 24 additions and 8 deletions
|
|
@ -21,14 +21,11 @@ FAILED=0
|
|||
# Uses awk instead of grep -Eo for busybox/Alpine compatibility (#296).
|
||||
get_fns() {
|
||||
local f="$1"
|
||||
# Use POSIX character classes and bracket-escaped parens for BusyBox awk
|
||||
# compatibility (BusyBox awk does not expand \t to tab in character classes
|
||||
# and may handle \( differently in ERE patterns).
|
||||
awk '/^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]+[[:space:]]*[(][)]/ {
|
||||
sub(/^[[:space:]]+/, "")
|
||||
sub(/[[:space:]]*[(][)].*/, "")
|
||||
print
|
||||
}' "$f" 2>/dev/null | sort -u || true
|
||||
# Use grep+sed instead of awk for BusyBox compatibility — BusyBox awk
|
||||
# unreliably handles [(][)] bracket expressions in some Alpine builds.
|
||||
grep -E '^[[:space:]]*[a-zA-Z_][a-zA-Z0-9_]+[[:space:]]*\(\)' "$f" 2>/dev/null \
|
||||
| sed 's/^[[:space:]]*//; s/[[:space:]]*().*$//' \
|
||||
| sort -u || true
|
||||
}
|
||||
|
||||
# Extract call-position identifiers that look like custom function calls:
|
||||
|
|
|
|||
19
bin/disinto
19
bin/disinto
|
|
@ -808,6 +808,14 @@ OPSEOF
|
|||
|
||||
# Commit and push seed content
|
||||
if [ "$seeded" = true ] && [ -d "${ops_root}/.git" ]; then
|
||||
# Auto-configure repo-local git identity if missing (#778)
|
||||
if [ -z "$(git -C "$ops_root" config user.name 2>/dev/null)" ]; then
|
||||
git -C "$ops_root" config user.name "disinto-admin"
|
||||
fi
|
||||
if [ -z "$(git -C "$ops_root" config user.email 2>/dev/null)" ]; then
|
||||
git -C "$ops_root" config user.email "disinto-admin@localhost"
|
||||
fi
|
||||
|
||||
git -C "$ops_root" add -A
|
||||
if ! git -C "$ops_root" diff --cached --quiet 2>/dev/null; then
|
||||
git -C "$ops_root" commit -m "chore: seed ops repo structure" -q
|
||||
|
|
@ -947,6 +955,17 @@ preflight_check() {
|
|||
fi
|
||||
fi
|
||||
|
||||
# ── Git identity check ──
|
||||
if command -v git &>/dev/null; then
|
||||
local git_name git_email
|
||||
git_name=$(git config user.name 2>/dev/null) || git_name=""
|
||||
git_email=$(git config user.email 2>/dev/null) || git_email=""
|
||||
if [ -z "$git_name" ] || [ -z "$git_email" ]; then
|
||||
echo "Warning: git user.name/user.email not configured" >&2
|
||||
echo " Init will set a repo-local identity for ops commits" >&2
|
||||
fi
|
||||
fi
|
||||
|
||||
# ── Optional tools (warn only) ──
|
||||
if ! command -v docker &>/dev/null; then
|
||||
echo "Warning: docker not found (needed for Forgejo provisioning)" >&2
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue