Update 2025-04-13_17:35:58
This commit is contained in:
		| @ -1,10 +1,21 @@ | |||||||
| #!/bin/zsh | #!/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. | # 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 | # 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 | # Try to extract GITEA_API_TOKEN from ~/.gitea_token if not set | ||||||
| if [ -z "$GITEA_API_TOKEN" ] && [ -f "$HOME/.gitea_token" ]; then | if [ -z "$GITEA_API_TOKEN" ] && [ -f "$HOME/.gitea_token" ]; then | ||||||
|   GITEA_API_TOKEN=$(<"$HOME/.gitea_token") |   GITEA_API_TOKEN=$(<"$HOME/.gitea_token") | ||||||
| @ -197,6 +208,12 @@ if [ ! -d .git ]; then | |||||||
|   git config init.defaultBranch main |   git config init.defaultBranch main | ||||||
|   git checkout -b main |   git checkout -b main | ||||||
| else | 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" |   log DEBUG ".git directory already present" | ||||||
| fi | fi | ||||||
|  |  | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 root
					root