Update 2025-04-13_17:35:58

This commit is contained in:
root
2025-04-13 17:35:58 +02:00
parent 535c2a093d
commit 1f5954390b

View File

@ -1,10 +1,21 @@
#!/bin/zsh
# Script Version: 1.5
# Script Version: 1.6
# Description: Pushes the current folder (e.g. /etc) to a nested Gitea repo using provided nesting arguments. Auto-creates the remote repo via Gitea API if missing.
# Set variables
# ========
# Ensure Git user identity is configured
log DEBUG "Checking Git user configuration..."
if ! git config --global user.name >/dev/null 2>&1; then
git config --global user.name "$(whoami)"
log DEBUG "Set Git user.name to $(whoami)"
fi
if ! git config --global user.email >/dev/null 2>&1; then
git config --global user.email "$(whoami)@$(hostname -f)"
log DEBUG "Set Git user.email to $(whoami)@$(hostname -f)"
fi
# Try to extract GITEA_API_TOKEN from ~/.gitea_token if not set
if [ -z "$GITEA_API_TOKEN" ] && [ -f "$HOME/.gitea_token" ]; then
GITEA_API_TOKEN=$(<"$HOME/.gitea_token")
@ -197,6 +208,12 @@ if [ ! -d .git ]; then
git config init.defaultBranch main
git checkout -b main
else
CURRENT_BRANCH=$(git symbolic-ref --short HEAD 2>/dev/null)
if [ "$CURRENT_BRANCH" != "main" ]; then
log WARNING "Current branch is '$CURRENT_BRANCH', renaming to 'main'"
git branch -m main
fi
log DEBUG ".git directory already present"
log DEBUG ".git directory already present"
fi