fix: macOS install — bash 3.2, remotes и awk для SSH config
setup-git-ssh.sh работает без declare -A; Set-GitRemotes не дублирует .git и не падает на пустом legacy; shell-скрипты executable.
This commit is contained in:
+16
-11
@@ -16,9 +16,11 @@ if ! git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
|
||||
fi
|
||||
|
||||
repo_name_from_url() {
|
||||
local url="$1"
|
||||
if [[ "$url" =~ /([^/]+)(\.git)?/?$ ]]; then
|
||||
echo "${BASH_REMATCH[1]}"
|
||||
local url="$1" name=""
|
||||
if [[ "$url" =~ /([^/]+)/?$ ]]; then
|
||||
name="${BASH_REMATCH[1]}"
|
||||
name="${name%.git}"
|
||||
printf '%s\n' "$name"
|
||||
fi
|
||||
}
|
||||
|
||||
@@ -32,6 +34,7 @@ if [[ -z "$repo_name" ]]; then
|
||||
done
|
||||
fi
|
||||
repo_name="${repo_name:-$(basename "$(git rev-parse --show-toplevel)")}"
|
||||
repo_name="${repo_name%.git}"
|
||||
home_url="ssh://git@git.papatramp.ru:2222/${OWNER}/${repo_name}.git"
|
||||
kalinamall_url="ssh://git@git.kalinamall.ru:2222/${OWNER}/${repo_name}.git"
|
||||
github_url="git@github.com:${GITHUB_ORG}/${repo_name}.git"
|
||||
@@ -83,14 +86,16 @@ set_remote() {
|
||||
*) 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
|
||||
if ((${#legacy[@]} > 0)); then
|
||||
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
|
||||
fi
|
||||
|
||||
git remote add "$name" "$url"
|
||||
log_ok "remote $name added -> $url"
|
||||
|
||||
Reference in New Issue
Block a user