diff options
-rw-r--r-- | Makefile | 3 | ||||
-rw-r--r-- | dot/gitconfig | 14 | ||||
-rwxr-xr-x | src/gitconfig.sh | 29 |
3 files changed, 32 insertions, 14 deletions
@@ -6,6 +6,9 @@ DOTFILES := $(shell find dot \( -type f -o -type l \) -not -name '.*') | |||
6 | 6 | ||
7 | DESTINATIONS = $(DOTFILES:dot/%=${HOME}/.%) | 7 | DESTINATIONS = $(DOTFILES:dot/%=${HOME}/.%) |
8 | 8 | ||
9 | ${HOME}/.gitconfig: | ||
10 | ./src/gitconfig.sh | ||
11 | |||
9 | EXECUTABLES = $(filter dot/local/bin/%, $(DOTFILES)) | 12 | EXECUTABLES = $(filter dot/local/bin/%, $(DOTFILES)) |
10 | 13 | ||
11 | $(HOME)/.%: dot/% | 14 | $(HOME)/.%: dot/% |
diff --git a/dot/gitconfig b/dot/gitconfig deleted file mode 100644 index 6d9e2ed..0000000 --- a/dot/gitconfig +++ /dev/null | |||
@@ -1,14 +0,0 @@ | |||
1 | [user] | ||
2 | email = d@jerkface.net | ||
3 | name = Andrew Cady | ||
4 | [sendemail] | ||
5 | from = Andrew Cady <d@jerkface.net> | ||
6 | smtpencryption = tls | ||
7 | smtpserver = smtp.gmail.com | ||
8 | smtpuser = andrew.cady@gmail.com | ||
9 | smtpserverport = 587 | ||
10 | suppressfrom = yes | ||
11 | [credential] | ||
12 | helper = cache | ||
13 | [core] | ||
14 | excludesfile = /home/d/.config/git/ignore | ||
diff --git a/src/gitconfig.sh b/src/gitconfig.sh new file mode 100755 index 0000000..3a7e824 --- /dev/null +++ b/src/gitconfig.sh | |||
@@ -0,0 +1,29 @@ | |||
1 | #!/bin/sh | ||
2 | target=~/.gitconfig | ||
3 | if [ -z "$OVERWRITE_GITCONFIG" ] && [ -e "$target" ] | ||
4 | then | ||
5 | exit | ||
6 | fi | ||
7 | |||
8 | user=$(id -un) || exit | ||
9 | [ "$user" ] || exit | ||
10 | email=${user}@$(hostname --fqdn) || exit | ||
11 | [ "$email" ] || exit | ||
12 | name=$(getent passwd "$user" | cut -d: -f2) || : ok | ||
13 | temp=$(mktemp ~/.gitconfig.tmp.XXX) || exit | ||
14 | [ "$temp" ] || exit | ||
15 | |||
16 | gitconfig() | ||
17 | { | ||
18 | cat <<END | ||
19 | [user] | ||
20 | email = ${email} | ||
21 | name = ${name:-$email} | ||
22 | [core] | ||
23 | excludesfile = ~/.config/git/ignore | ||
24 | END | ||
25 | } | ||
26 | |||
27 | gitconfig > "$temp" && | ||
28 | mv "$temp" "$target" || | ||
29 | rm -f "$temp" | ||