-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdco
More file actions
executable file
·33 lines (29 loc) · 992 Bytes
/
Copy pathdco
File metadata and controls
executable file
·33 lines (29 loc) · 992 Bytes
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
#!/bin/bash
# DCO sign-off check. Verifies every non-merge commit in a range carries a
# 'Signed-off-by:' trailer matching the commit author (name <email>).
# This is the homebaked replacement for the DCO GitHub App.
#
# Usage: ./dco [<range>] (default: origin/master..HEAD)
set -u
range="${1:-origin/master..HEAD}"
fail=0
checked=0
while read -r sha; do
[[ -z "$sha" ]] && continue
# Skip merge commits (more than one parent) — sign-off lives on the real commits.
if (( $(git rev-list --parents -n1 "$sha" | wc -w) > 2 )); then
continue
fi
checked=$((checked + 1))
author=$(git show -s --format='%an <%ae>' "$sha")
short=$(git show -s --format='%h' "$sha")
if ! git show -s --format='%(trailers:key=Signed-off-by,valueonly)' "$sha" \
| grep -qxF "$author"; then
echo "FAIL [$short]: missing 'Signed-off-by: $author'"
fail=1
fi
done < <(git rev-list "$range")
if [[ $fail -eq 0 ]]; then
echo "ok: $checked commit(s) carry a matching DCO sign-off"
fi
exit $fail