From ada9acf21870e81a9d72e9046e07089227eb85c9 Mon Sep 17 00:00:00 2001 From: "Xinwei Xiong(cubxxw-openim)" <3293172751nss@gmail.com> Date: Tue, 4 Jul 2023 16:17:18 +0800 Subject: [PATCH] feat: add git hook sign Signed-off-by: Xinwei Xiong(cubxxw-openim) <3293172751nss@gmail.com> --- .github/workflows/openim-ci.yml | 2 +- scripts/githooks/commit-msg | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/.github/workflows/openim-ci.yml b/.github/workflows/openim-ci.yml index e063c6e3b..d58211444 100644 --- a/.github/workflows/openim-ci.yml +++ b/.github/workflows/openim-ci.yml @@ -19,7 +19,7 @@ jobs: strategy: matrix: - go_version: [1.18, 1.19, 1.20] + go_version: ['1.18', '1.19', '1.20'] os: [ubuntu-latest, macOS-latest] steps: diff --git a/scripts/githooks/commit-msg b/scripts/githooks/commit-msg index bf00bfc31..99f4067b9 100644 --- a/scripts/githooks/commit-msg +++ b/scripts/githooks/commit-msg @@ -75,4 +75,18 @@ then printError "Please fix your commit message to match kubecub coding standards" printError "https://gist.github.com/cubxxw/126b72104ac0b0ca484c9db09c3e5694#file-githook-md" exit 1 +fi + +### Add Sign-off-by line to the end of the commit message +# Get local git config +NAME=$(git config user.name) +EMAIL=$(git config user.email) + +# Check if the commit message contains a sign-off line +grep -qs "^Signed-off-by: " "$1" +SIGNED_OFF_BY_EXISTS=$? + +# Add "Signed-off-by" line if it doesn't exist +if [ $SIGNED_OFF_BY_EXISTS -ne 0 ]; then + echo -e "\nSigned-off-by: $NAME <$EMAIL>" >> "$1" fi \ No newline at end of file