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:
parent
33f7408ef1
commit
2192cb5148
1 changed files with 15 additions and 3 deletions
|
|
@ -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.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue