From 64def776ff1d0d47b64a400c27cb8e5ca9093b9d Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Mon, 17 Feb 2014 22:59:05 -0500 Subject: [PATCH 13/23] Don't output error when checking files that have been removed and don't exists. --- git_hooks/pre-commit/copyrightyear | 5 ++++- git_hooks/pre-commit/stylecheck_bash | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git git_hooks/pre-commit/copyrightyear git_hooks/pre-commit/copyrightyear index a5d14e3..ce5fe21 100755 --- git_hooks/pre-commit/copyrightyear +++ git_hooks/pre-commit/copyrightyear @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2010, Benjamin C. Meyer +# Copyright (c) 2010-2014, Benjamin C. Meyer # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -27,6 +27,9 @@ # function test_file { + if [ ! -f $file ] ; then + return + fi year=`date +%Y` echo "--checking copyright year: $file" grep $year $file >> /dev/null diff --git git_hooks/pre-commit/stylecheck_bash git_hooks/pre-commit/stylecheck_bash index 57ecb30..fe582f2 100755 --- git_hooks/pre-commit/stylecheck_bash +++ git_hooks/pre-commit/stylecheck_bash @@ -1,6 +1,6 @@ #!/bin/bash # -# Copyright (c) 2010, Benjamin C. Meyer +# Copyright (c) 2010-2014, Benjamin C. Meyer # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -30,6 +30,9 @@ dir=`dirname $0` function test_file { file="${1}" + if [ ! -f "${file}" ] ; then + return + fi echo "--checking style via bash hack: $file" GITDIR=`git rev-parse --git-dir` cd $GITDIR/../ -- 2.44.0