pi-web-runtime / sandbox /git-credential-huggingface
Mike0021's picture
Runtime image for Pi Web workspace machines
df3a27a verified
Raw History Blame Contribute Delete
521 Bytes
#!/bin/sh
# Git credential helper for huggingface.co (set in /etc/gitconfig): answers with the token
# the Space lent to the agent through Sign in with Hugging Face, if there is one, so the
# token never ends up in a remote URL or in .git/config.
cat >/dev/null
[ "$1" = "get" ] || exit 0
dir="${HF_HOME:-$HOME/.cache/huggingface}"
[ -s "$dir/token" ] || exit 0
user=$(sed -n 's/.*"user": *"\([^"]*\)".*/\1/p' "$dir/hfpi-identity.json" 2>/dev/null)
printf 'username=%s\npassword=%s\n' "${user:-hf}" "$(cat "$dir/token")"