wesaynih / infrastructure

© 2016 The Knights Who Say NIH — Do NOT fork this repository without permission.
http://frameless.io/
Other
0 stars 1 forks source link

Require GPG signed commits #52

Open Robbert opened 8 years ago

Robbert commented 8 years ago

Related reading: Github: Generating a GPG key

Robbert commented 8 years ago

We should try to find the $INSERT_KEY_HERE automatically

Work in progress attempt:

gpg --list-keys  --with-colons gpg "`git config --global user.email`" | grep '^pub:[[:alpha:]]:[[:digit:]]\{4\}:1:[[:alnum:]]\{8\}\([[:alnum:]]\{8\}\)'
Robbert commented 8 years ago

OK, it turns out there is a very simple UNIX utility called cut that can find values delimiter separated columns, CSV for example, but also values from colon separated columns.

Using that now:

gpg --with-colons --list-keys $GIT_COMMITTER_EMAIL \
    grep ^pub                       | # Show only public keys
    sort                            | # Sort by key strength
    tail -n 1                       | # Only use the strongest key (from the last line)
    cut -d : -f 5                   | # Only output the key ID column
    grep -o "\([[:alnum:]]\)\{8\}$"   # Only output the last eight characters
Robbert commented 8 years ago

@Yolijn Would you please also setup GPG on your computers?