-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathverify-all-git.sh
More file actions
executable file
·32 lines (24 loc) · 1.01 KB
/
Copy pathverify-all-git.sh
File metadata and controls
executable file
·32 lines (24 loc) · 1.01 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
#!/usr/bin/env bash
# Function to verify a commit and re-sign if not verified
verify_and_sign_commit() {
local commit_hash=$1
echo "Checking commit $commit_hash..."
verification_result=$(git verify-commit $commit_hash 2>&1)
if [[ $verification_result == *"No signature"* || $verification_result == *"BAD signature"* ]]; then
echo "Commit $commit_hash is not signed or has a bad signature. Re-signing..."
# checkout and resign
git checkout $commit_hash
git commit --amend --no-edit -S
# continue rebase
git rebase --continue || exit 1
else
echo "Commit $commit_hash is signed and verified."
fi
echo
}
# start the process from the root commit
git rebase --interactive --root
# iterate through all commits in the repository and sign those that are not verified
git rev-list --all | while read commit_hash; do
verify_and_sign_commit $commit_hash
done