Files
jsc-marketplace/plugins/jsc-skills/skills/herdr-issue/scripts/git-credential.sh
T
rootandClaude Sonnet 5.5 26fbf9ae30 refactor: 技能統一收進 jsc-skills,加入 herdr,版本統一為 0.0.1
- 新增 jsc-skills plugin,含 herdr、herdr-issue、ingest,以 /jsc-skills:<名稱> 呼叫
- ingest 自 companion 移入,移除獨立的 herdr-issue plugin
- companion 版本由 0.0.3 改為 0.0.1

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-13 07:29:05 +00:00

25 lines
1.2 KiB
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.
#!/usr/bin/env bash
# git credential helper:用 tea 預設 login 的帳號與 token 回應 HTTPS 認證,避免 git 要互動輸入帳密
# ("could not read Username ... No such device or address")。只處理 get,且只回應該 login 的主機。
[ "${1:-}" = get ] || exit 0
exec python3 -c '
import os, sys
req = dict(l.split("=", 1) for l in sys.stdin.read().splitlines() if "=" in l)
cfg = os.path.join(os.environ.get("XDG_CONFIG_HOME") or os.path.expanduser("~/.config"), "tea", "config.yml")
logins, cur = [], None
for line in open(cfg):
s = line.strip()
if s.startswith("- name:"):
cur = {"name": s.split(":", 1)[1].strip()}; logins.append(cur)
elif cur is not None and ":" in s:
k, v = s.split(":", 1)
if k in ("url", "token", "user", "default"): cur[k] = v.strip().strip("\"\x27")
want = os.environ.get("HERDR_ISSUE_LOGIN")
pick = next((l for l in logins if l["name"] == want), None) if want else None
pick = pick or next((l for l in logins if l.get("default") == "true"), None)
if not pick or not pick.get("token"): sys.exit(0)
host = pick["url"].split("://", 1)[-1].rstrip("/")
if req.get("host") != host: sys.exit(0)
print("username=" + pick["user"]); print("password=" + pick["token"])
'