Files
ISEP/scripts/git-credential-gitea.sh
T

27 lines
881 B
Bash
Executable File
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# git-credential-gitea.sh — git credential helper:把 Gitea 憑證從 env.env 餵給 git
# 讓 remote URL 不必嵌 tokeninkstone/ISEP#47)。URL 乾淨 ⇒ git 把它印出來也不洩 token。
#
# 安裝(gitea-bootstrap.sh 會自動設好,這裡是手動法):
# git config credential.helper "$(git rev-parse --show-toplevel)/scripts/git-credential-gitea.sh"
# 只對 git.uncle6.me 的 get 供憑證;storeerase 不做事(token 不由 git 保管)。
DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$DIR/lib/gitea-token.sh"
[ "${1:-}" = "get" ] || exit 0
HOST=""
while IFS='=' read -r k v; do
[ -z "$k" ] && break
[ "$k" = "host" ] && HOST="$v"
done
case "$HOST" in
git.uncle6.me|"") : ;;
*) exit 0 ;;
esac
TOK=$(gitea_token) || exit 0
[ -n "$TOK" ] || exit 0
printf 'username=claude-code\n'
printf 'password=%s\n' "$TOK"