-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_gitconfig.tmpl
More file actions
99 lines (87 loc) · 3.38 KB
/
Copy pathdot_gitconfig.tmpl
File metadata and controls
99 lines (87 loc) · 3.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
{{- $cfg := includeTemplate ".chezmoitemplates/effective-config.json.tmpl" . | fromJson -}}
{{- $identity := $cfg.identity | default dict -}}
{{- $git := $cfg.git | default dict -}}
{{- $provider := $cfg.active_provider | default "gh" -}}
{{- $personalSigningKey := printf "~/.ssh/signing-pubs/personal-%s.pub" $provider -}}
{{- $personalSigningKeyAbs := joinPath .chezmoi.homeDir ".ssh" "signing-pubs" (printf "personal-%s.pub" $provider) -}}
{{- $signingEnabled := true -}}
{{- if hasKey $git "signing_enabled" -}}
{{- $signingEnabled = (index $git "signing_enabled") -}}
{{- end -}}
{{- $commitSigningEnabled := true -}}
{{- if hasKey $git "commit_gpgsign" -}}
{{- $commitSigningEnabled = (index $git "commit_gpgsign") -}}
{{- end -}}
{{- $tagSigningEnabled := true -}}
{{- if hasKey $git "tag_gpgsign" -}}
{{- $tagSigningEnabled = (index $git "tag_gpgsign") -}}
{{- end -}}
{{- $personalSigningReady := false -}}
{{- if and $signingEnabled (stat $personalSigningKeyAbs) -}}
{{- $personalSigningReady = true -}}
{{- end -}}
{{- $personalRewriteHost := ternary "gitlab.com-personal" "github.zerozr99.workers.dev-personal" (eq $provider "gl") -}}
[pull]
rebase = true
[core]
excludesfile = ~/.gitignore
editor = nano
[diff]
external = difft
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[gpg]
format = ssh
[gpg "ssh"]
{{- if eq .chezmoi.os "darwin" }}
program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign
{{- else }}
program = op-ssh-sign
{{- end }}
[commit]
gpgsign = {{ and $commitSigningEnabled $personalSigningReady }}
[tag]
gpgSign = {{ and $tagSigningEnabled $personalSigningReady }}
[alias]
permission-reset = !git diff -p -R --no-ext-diff --no-color | grep -E "^(diff|(old|new) mode)" --color=never | git apply
p = !git push -u origin $(git rev-parse --abbrev-ref HEAD)
st = status -sb
ll = log --oneline
last = log -1 HEAD --stat
cm = commit -v -m
gl = config --global -l
up = !git fetch --all --prune && git rebase
gl-mr = !glab-auto mr create --yes --push --remove-source-branch -f -t
gl-mrd = !glab-auto mr update --draft
gl-mrr = !glab-auto mr update --ready
gh-mr = !gh pr create
df = diff
[user]
name = {{ ((index $identity "git_name") | default "Unknown User") | quote }}
email = {{ ((index $identity "git_email") | default "") | quote }}
{{- if $personalSigningReady }}
signingkey = {{ $personalSigningKey | quote }}
{{- else if $signingEnabled }}
# signingkey intentionally omitted until {{ $personalSigningKey }} exists and matches a 1Password SSH key item.
{{- end }}
{{- if eq $provider "gl" }}
[url "git@{{ $personalRewriteHost }}:"]
insteadOf = git@gitlab.com:
{{- else }}
[url "git@{{ $personalRewriteHost }}:"]
insteadOf = git@github.com:
{{- end }}
# Local work contexts are path-scoped and generated from:
# ~/.config/dotfiles/work-contexts/*.toml
{{- range $slug := ($cfg.selected_work_contexts | default list) }}
{{- $ctx := index ($cfg.work_contexts | default dict) $slug | default dict }}
{{- $match := (index $ctx "match") | default dict }}
{{- range $dir := ((index $match "directories") | default list) }}
{{- $expandedDir := regexReplaceAll "^~" $dir (env "HOME") | trimSuffix "/" }}
[includeIf "gitdir:{{ $expandedDir }}/.git"]
path = {{ printf "~/.config/dotfiles/generated/git/work-%s.gitconfig" $slug | quote }}
{{- end }}
{{- end }}