From 5a5d780e9803f891330a357d3d6fdf14092d1e26 Mon Sep 17 00:00:00 2001 From: Patrick Baudin <patrick.baudin@cea.fr> Date: Wed, 20 Jul 2022 15:26:58 +0200 Subject: [PATCH] [Tools] pre-commit hook: prints the unstaged file list. --- tools/git-hooks/pre-commit.sh | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/tools/git-hooks/pre-commit.sh b/tools/git-hooks/pre-commit.sh index a2aff6d4d5f..06213edd6b1 100755 --- a/tools/git-hooks/pre-commit.sh +++ b/tools/git-hooks/pre-commit.sh @@ -28,8 +28,16 @@ # Note: # - that checks the unstaged version of the files and these files are # only commited with a `git commit -a` command. -# - so, a `git commit` command may checks the wrong version of a file. +# - so, a `git commit` command may checks the wrong version of a file. -echo "Pre-commit Hook looking at staged and unstaged file version..." -## looks at unstaged and staged files +echo "Pre-commit Hook..." + +# Extract the files that have an unstaged version +UNSTAGED="git diff --name-status" +if [ "$(${UNSTAGED} | wc -l)" != "0" ]; then + echo "WARNING: These files will only be verified for a 'git commit -a' command." + ${UNSTAGED} +fi + +# Verifies the current version of files make lint.before-commit-a -- GitLab