File tree 1 file changed +4
-2
lines changed
1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
3
current_keys=" $( gpg --list-keys --with-colons | grep ' ^pub' | cut -d: -f5) "
4
+ last_commit_key_id=" $( git log --show-signature | grep " Primary key fingerprint" | head -n 1 | tail -c 20 | tr -d ' ' ) "
4
5
5
6
new_keylist=" $( mktemp) "
6
7
for keyfile in keys/* .asc; do gpg --with-colons " $keyfile " 2> /dev/null | grep ' ^pub' | cut -d: -f5; done > " $new_keylist "
7
- # Remove keys that are no longer present
8
+ # Remove keys that are no longer present.
9
+ # But, as a safeguard, never allow removal of key that signed last commit.
8
10
for key in $current_keys ; do
9
- if ! grep -qs " $key " " $new_keylist " ; then
11
+ if ! grep -qs " $key " " $new_keylist " && [[ " $key " != " $last_commit_key_id " ]] ; then
10
12
echo " Removing key $key ..."
11
13
gpg --batch --yes --delete-keys " $key "
12
14
fi
You can’t perform that action at this time.
0 commit comments