From 678d7cc45afb849b01c7b755f1b5b638a0d588b6 Mon Sep 17 00:00:00 2001 From: mpl Date: Fri, 6 Jun 2014 18:33:54 +0200 Subject: [PATCH] misc/pre-commit.githook: print gofmt to run Change-Id: I1e177a2cbbc33bae2afc9bcef8c3da387f5bb303 --- misc/pre-commit.githook | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/misc/pre-commit.githook b/misc/pre-commit.githook index d67920ac6..1bb12ad0e 100755 --- a/misc/pre-commit.githook +++ b/misc/pre-commit.githook @@ -18,6 +18,7 @@ fi #gofmt and trailing space errors committed=`git diff-index --cached --name-only HEAD` +needFmt="" for c in $committed do if [ ! -e "$c" ] @@ -31,7 +32,7 @@ do fmtdiff=`git show ":$c" | gofmt -d 2>&1` if [ -n "$fmtdiff" ] then - echo "gofmt needed on "$c + needFmt="$needFmt $gofile" exitstatus=1 fi fi @@ -47,6 +48,10 @@ do done if [ "$exitstatus" -ne 0 ] then + if [ -n "$needFmt" ] + then + echo "gofmt -w $needFmt" + fi echo "You can override this check with 'git commit --no-verify'" fi