Skip to content

Commit 15403ca

Browse files
committed
Use GPG signing on codespaces
1 parent 0c4a49f commit 15403ca

File tree

4 files changed

+30
-25
lines changed

4 files changed

+30
-25
lines changed

chezmoi/dot_config/git/config.tmpl

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,11 @@
1616
useConfigOnly = true
1717
name = Colin Seymour
1818
19-
#signingkey = 88109C73073E7080
19+
{{- if .codespaces }}
20+
signingkey = 88109C73073E7080 # GitHub doesn't play nice with verifying SSH signed commits from Codespaces due to it setting GIT_COMMITTER_EMAIL and GIT_COMMITTER_NAME
21+
{{- else }}
2022
signingkey = ~/.ssh/git_signing_ed25519.pub
23+
{{- end }}
2124

2225
# Override default when working in work repos
2326
[includeIf "hasconfig:remote.*.url:ssh://[email protected]/github/*"] # Requires git 2.36.0 later
@@ -128,22 +131,20 @@
128131
gpgSign = true
129132

130133
[gpg]
131-
format = ssh
132-
# {{- if .codespaces }}
133-
# program = /.codespaces/bin/gh-gpgsign
134-
# {{- else }}
134+
{{- if .codespaces }}
135+
program = /.codespaces/bin/gh-gpgsign
136+
{{- else }}
137+
format = ssh # Use SSH everywhere other than Codespaces for now.
135138
# program = {{- lookPath "gpg" }}
136-
# {{- end }}
139+
{{- end }}
137140

141+
{{- if .codespaces }}
138142
[gpg "ssh"]
139143
allowedSignersFile = ~/.ssh/allowed_signers
144+
{{- end }}
140145

141146
[merge]
142-
{{- $v := output "git" "--version" | trim | split " " }}{{ if semverCompare ">2.35.0" $v._2 }}
143-
conflictstyle = zdiff3 # Requires git 2.35 or later which isn't available on Codespaces by default
144-
{{- else }}
145-
conflictstyle = diff3
146-
{{- end }}
147+
conflictstyle = zdiff3
147148

148149
[protocol]
149150
version = 2
@@ -156,9 +157,7 @@
156157

157158
[pull]
158159
rebase = false
159-
{{- $v := output "git" "--version" | trim | split " " }}{{ if semverCompare ">2.33.0" $v._2 }}
160-
twohead = ort # Requires git 2.33 or later which isn't available on Codespaces by default
161-
{{- end }}
160+
twohead = ort
162161

163162
[advice]
164163
detachedHead = false

chezmoi/dot_config/git/gitconfig.work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# vim: set filetype=ini
12
[user]
23
name = Colin Seymour
34

chezmoi/dot_config/zsh/private_dot_zshrc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,6 @@ if [ -n "$CODESPACES" ]; then
118118
export GOPRIVATE=
119119
export GONOPROXY=
120120
export GONOSUMDB='github.com/github/*'
121-
# Unset these as GitHub doesn't verify commits by the default GitHub <[email protected]> set by default in Codespaces
122-
# This doesn't help things if you use the UI to commit
123-
unset GIT_COMMITTER_EMAIL
124-
unset GIT_COMMITTER_NAME
125121
fi
126122
export HOMEBREW_BUNDLE_FILE=$XDG_CONFIG_HOME/homebrew/Brewfile
127123
export IRBRC=$XDG_CONFIG_HOME/irb/irbrc

script/codespaces-post-start

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ if [ ! -f "${HOME}/.netrc" ] || grep -vq "goproxy.githubapp.com" "${HOME}/.netrc
2121
echo "machine goproxy.githubapp.com login nobody password $GITHUB_TOKEN" >> "$HOME/.netrc"
2222
fi
2323

24-
if [ ! -f "${HOME}/.ssh/git_signing_ed25519" ]; then
25-
# Takes this from my Codespaces secrets config on GitHub
26-
echo "$GIT_SIGNING_KEY" > "${HOME}/.ssh/git_signing_ed25519"
27-
chmod 600 "${HOME}/.ssh/git_signing_ed25519"
28-
fi
24+
# Commented out as Codespaces has this annoying habit of setting GIT_COMMITTER_EMAIL and GIT_COMMITTER_NAME
25+
# to GitHub <[email protected]> respectively. GitHub doesn't sign commits by this user and thus doesn't verify them
26+
# either. The verification also completely ignores the author attribute in the commit.
27+
#
28+
# Unsetting these env vars "works around" the issue but then the Codespace becomes quite unstable for some reason
29+
# so we're going to have to stick with GPG on Codespaces for now.
30+
#
31+
# Revisit this occasionally.
32+
#
33+
# if [ ! -f "${HOME}/.ssh/git_signing_ed25519" ]; then
34+
# # Takes this from my Codespaces secrets config on GitHub
35+
# echo "$GIT_SIGNING_KEY" > "${HOME}/.ssh/git_signing_ed25519"
36+
# chmod 600 "${HOME}/.ssh/git_signing_ed25519"
37+
# fi
2938

3039
# Unset these as GitHub doesn't verify commits by the default GitHub <[email protected]> set by default in Codespaces
31-
unset GIT_COMMITTER_EMAIL
32-
unset GIT_COMMITTER_NAME
40+
# unset GIT_COMMITTER_EMAIL
41+
# unset GIT_COMMITTER_NAME

0 commit comments

Comments
 (0)