From d7586550705760dbea9e49adb1256dda77107ceb Mon Sep 17 00:00:00 2001 From: Esther Schmitz Date: Fri, 5 Jun 2026 16:10:58 +0200 Subject: [PATCH] chore(ci): auto-append Signed-off-by via husky prepare-commit-msg Adds a husky prepare-commit-msg hook that appends a Signed-off-by trailer using the committer's git identity. DCO checks now pass without contributors having to remember -s on every commit. The hook is idempotent (skips if trailer already present) and skips merge/squash/commit sources where git generates the message itself or reuses an existing one (e.g. amend, rebase pickup). Signed-off-by: Esther Schmitz --- .husky/prepare-commit-msg | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100755 .husky/prepare-commit-msg diff --git a/.husky/prepare-commit-msg b/.husky/prepare-commit-msg new file mode 100755 index 0000000000..46bbdc8905 --- /dev/null +++ b/.husky/prepare-commit-msg @@ -0,0 +1,30 @@ +#!/usr/bin/env bash +# SPDX-FileCopyrightText: 2026 SAP SE or an SAP affiliate company and Juno contributors +# SPDX-License-Identifier: Apache-2.0 +# .husky/prepare-commit-msg +# +# Auto-append a Signed-off-by trailer using the committer's git identity, +# satisfying the DCO check. Skips merge/squash/amend commits and is a no-op +# if the trailer is already present. + +COMMIT_MSG_FILE="$1" +COMMIT_SOURCE="$2" + +case "$COMMIT_SOURCE" in + merge|squash|commit) exit 0 ;; +esac + +NAME="$(git config user.name)" +EMAIL="$(git config user.email)" + +if [ -z "$NAME" ] || [ -z "$EMAIL" ]; then + exit 0 +fi + +TRAILER="Signed-off-by: $NAME <$EMAIL>" + +if grep -qFx "$TRAILER" "$COMMIT_MSG_FILE"; then + exit 0 +fi + +git interpret-trailers --if-exists addIfDifferent --trailer "$TRAILER" --in-place "$COMMIT_MSG_FILE"