27 lines
881 B
Bash
Executable File
27 lines
881 B
Bash
Executable File
#!/bin/sh
|
||
# git-credential-gitea.sh — git credential helper:把 Gitea 憑證從 env/.env 餵給 git,
|
||
# 讓 remote URL 不必嵌 token(inkstone/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 供憑證;store/erase 不做事(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"
|