Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .husky/prepare-commit-msg
Original file line number Diff line number Diff line change
@@ -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
Comment thread
edda marked this conversation as resolved.

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"
Loading