Добавить bootstrap для новых ПК и Linux-скрипты.
SSH-ключи и Gitea API до clone Rules; init-cursor копирует из локального $HOME/CursorRules.
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
#!/usr/bin/env bash
|
||||
# Стандартные git remote: home, kalinamall, github.
|
||||
set -euo pipefail
|
||||
|
||||
OWNER="${OWNER:-PapaTramp}"
|
||||
GITHUB_ORG="${GITHUB_ORG:-PTah}"
|
||||
REPO="${REPO:-}"
|
||||
SKIP_KALINAMALL="${SKIP_KALINAMALL:-0}"
|
||||
WHAT_IF="${WHAT_IF:-0}"
|
||||
|
||||
log_step() { printf '[*] %s\n' "$1"; }
|
||||
log_ok() { printf '[+] %s\n' "$1"; }
|
||||
|
||||
if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
echo 'Run inside a git repository or set REPO.' >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
repo_name="${REPO:-$(basename "$(git rev-parse --show-toplevel)")}"
|
||||
home_url="ssh://git@git.papatramp.lan:2222/${OWNER}/${repo_name}.git"
|
||||
kalinamall_url="ssh://git@git.kalinamall.lan:2222/${OWNER}/${repo_name}.git"
|
||||
github_url="git@github.com:${GITHUB_ORG}/${repo_name}.git"
|
||||
|
||||
set_remote() {
|
||||
local name="$1"
|
||||
local url="$2"
|
||||
local existing current old
|
||||
|
||||
if [[ "$WHAT_IF" == '1' ]]; then
|
||||
log_step "WhatIf: remote $name -> $url"
|
||||
return 0
|
||||
fi
|
||||
|
||||
if git remote | grep -Fxq "$name"; then
|
||||
current="$(git remote get-url "$name" | tr -d '\r\n')"
|
||||
if [[ "$current" == "$url" ]]; then
|
||||
log_ok "remote $name OK"
|
||||
return 0
|
||||
fi
|
||||
git remote set-url "$name" "$url"
|
||||
log_ok "remote $name updated -> $url"
|
||||
return 0
|
||||
fi
|
||||
|
||||
case "$name" in
|
||||
home) legacy=(gitea papatramp origin-home) ;;
|
||||
github) legacy=(origin) ;;
|
||||
kalinamall) legacy=(gitea-kalinamall kalina) ;;
|
||||
*) legacy=() ;;
|
||||
esac
|
||||
|
||||
for old in "${legacy[@]}"; do
|
||||
if git remote | grep -Fxq "$old"; then
|
||||
git remote rename "$old" "$name"
|
||||
git remote set-url "$name" "$url"
|
||||
log_ok "remote $old renamed to $name -> $url"
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
git remote add "$name" "$url"
|
||||
log_ok "remote $name added -> $url"
|
||||
}
|
||||
|
||||
log_step "Repo: $repo_name"
|
||||
set_remote home "$home_url"
|
||||
set_remote github "$github_url"
|
||||
if [[ "$SKIP_KALINAMALL" != '1' ]]; then
|
||||
set_remote kalinamall "$kalinamall_url"
|
||||
fi
|
||||
|
||||
printf '\n'
|
||||
git remote -v
|
||||
Reference in New Issue
Block a user