#!/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")"