From 6d0bbbc4ac2f3da9dca7c78bd4ac9c43504054fe Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Wed, 3 Sep 2014 00:26:18 +0200 Subject: [PATCH] Mention the commit ID and message when pushing single commits --- src/deforaos-git-hook.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/deforaos-git-hook.sh b/src/deforaos-git-hook.sh index 5d4d031..dc98736 100755 --- a/src/deforaos-git-hook.sh +++ b/src/deforaos-git-hook.sh @@ -83,12 +83,14 @@ _hook_update() #analyze each commit pushed revisions=$($GIT rev-list "${oldrev}..${newrev}") + message= commit_cnt=0 files_cnt=0 for revision in $revisions; do #$GIT cat-file commit "$revision" #count the file alterations files=$($GIT log -n 1 --name-only --pretty=format:'' "$revision") + [ -z "$message" ] && message=$($GIT log -n 1 --oneline "$revision") for file in $files; do files_cnt=$((files_cnt + 1)) done @@ -96,7 +98,11 @@ _hook_update() commit_cnt=$((commit_cnt + 1)) done if [ -n "$branch" ]; then - echo "[$branch] $commit_cnt $type(s) pushed ($files_cnt file(s) alterations)" + if [ $commit_cnt -eq 1 -a -n "$message" ]; then + echo "[$branch] $message ($files_cnt file(s) altered)" + else + echo "[$branch] $commit_cnt $type(s) pushed ($files_cnt file(s) altered)" + fi else echo "$refname: $commit_cnt $type(s) pushed ($files_cnt file(s) alterations)" fi