forge-login: don't die on RO ~/.config/git/config

home-manager / nix-managed git configs ship the file from the nix
store, so `git config --global` errors out. catch the failure and
print the equivalent home-manager snippet instead of aborting — the
tea + netrc steps still want to run.
This commit is contained in:
müde 2026-05-17 01:22:31 +02:00
parent 33f7408ef1
commit 2192cb5148

View file

@ -40,9 +40,21 @@ if [ -z "$token" ]; then
exit 1
fi
git config --global user.name "$username"
git config --global user.email "$email"
if git config --global user.name "$username" 2>/dev/null \
&& git config --global user.email "$email" 2>/dev/null; then
echo "git config: $username <$email>"
else
cat <<EOF
git config: --global write failed (read-only ~/.config/git/config?
home-manager / nix-managed setup). add this to your home-manager:
programs.git = {
enable = true;
userName = "$username";
userEmail = "$email";
};
EOF
fi
# netrc entry — git uses this for HTTP basic auth. 0600 because it
# contains the plaintext token.