From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 3B96C8DB1 for ; Mon, 7 Dec 2015 16:06:58 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 07 Dec 2015 07:06:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,395,1444719600"; d="scan'208";a="701826659" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga003.jf.intel.com with ESMTP; 07 Dec 2015 07:06:54 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id tB7F6rb8021970; Mon, 7 Dec 2015 15:06:53 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id tB7F6rfU028776; Mon, 7 Dec 2015 15:06:53 GMT Received: (from fyigit@localhost) by sivswdev02.ir.intel.com with id tB7F6r8B028772; Mon, 7 Dec 2015 15:06:53 GMT From: Ferruh Yigit To: dev@dpdk.org Date: Mon, 7 Dec 2015 15:06:52 +0000 Message-Id: <1449500812-28740-1-git-send-email-ferruh.yigit@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <20151207133216.GA11273@sivlogin002.ir.intel.com> References: <20151207133216.GA11273@sivlogin002.ir.intel.com> Subject: [dpdk-dev] [PATCH v3] scripts: add git hook scripts for checkpatch and auto doc generation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2015 15:06:59 -0000 These scripts are to automate some common tasks, scripts needs to be deployed to specific folder to become active. Scripts: post-commit: Triggers after commit complete, re-generates api and guides html documents. "RTE_DOC_OUT" environment variable configures document output folder. Same script can be used on server side with name "post-update", so documentation can auto updated after each push to server. post-merge: Same script as "post-commit", but triggered after git pull pre-commit: Does a checkpatch check before commit started. This script relies on scripts/checkpatches.sh script. checkpathes.sh should be running well to use this git hook script. This script can bypassed by commit "--no-verify" argument. Deployment: To make scripts active they need to be in /.git/hooks folder. Alternatively "deploy.sh" script can be used, it simply links all scripts into proper folder. Script names are significant and shouldn't changed. Signed-off-by: Ferruh Yigit --- mk/rte.sdkinstall.mk | 6 +++++- scripts/checkpatches.sh | 4 ++++ scripts/git-hooks/deploy.sh | 16 ++++++++++++++++ scripts/git-hooks/post-commit | 14 ++++++++++++++ scripts/git-hooks/post-merge | 1 + scripts/git-hooks/pre-commit | 13 +++++++++++++ 6 files changed, 53 insertions(+), 1 deletion(-) create mode 100755 scripts/git-hooks/deploy.sh create mode 100755 scripts/git-hooks/post-commit create mode 120000 scripts/git-hooks/post-merge create mode 100755 scripts/git-hooks/pre-commit diff --git a/mk/rte.sdkinstall.mk b/mk/rte.sdkinstall.mk index c611d45..8e67c07 100644 --- a/mk/rte.sdkinstall.mk +++ b/mk/rte.sdkinstall.mk @@ -139,7 +139,11 @@ install-sdk: tar -xf - -C $(DESTDIR)$(includedir) --strip-components=1 \ --keep-newer-files --warning=no-ignore-newer $(Q)$(call rte_mkdir, $(DESTDIR)$(sdkdir)) - $(Q)cp -a $(RTE_SDK)/{mk,scripts} $(DESTDIR)$(sdkdir) + $(Q)cp -a $(RTE_SDK)/mk $(DESTDIR)$(sdkdir) + $(Q)$(call rte_mkdir, $(DESTDIR)$(sdkdir)/scripts) + $(Q)tar -chf - -C $(RTE_SDK) scripts --exclude git-hooks | \ + tar -xf - -C $(DESTDIR)$(sdkdir)/scripts --strip-components=1 \ + --keep-newer-files --warning=no-ignore-newer $(Q)$(call rte_mkdir, $(DESTDIR)$(targetdir)) $(Q)cp -a $O/.config $(DESTDIR)$(targetdir) $(Q)$(call rte_symlink, $(DESTDIR)$(includedir), $(DESTDIR)$(targetdir)/include) diff --git a/scripts/checkpatches.sh b/scripts/checkpatches.sh index afc611b..6e841ba 100755 --- a/scripts/checkpatches.sh +++ b/scripts/checkpatches.sh @@ -66,6 +66,10 @@ while getopts hqv ARG ; do done shift $(($OPTIND - 1)) +if [ -z "$@" ]; then + exec $DPDK_CHECKPATCH_PATH -q $options - +fi + status=0 for p in "$@" ; do ! $verbose || printf '\n### %s\n\n' "$p" diff --git a/scripts/git-hooks/deploy.sh b/scripts/git-hooks/deploy.sh new file mode 100755 index 0000000..6b0147d --- /dev/null +++ b/scripts/git-hooks/deploy.sh @@ -0,0 +1,16 @@ + +SELF=$(basename $0) + +cd $(dirname $0) +FILES=$(ls | grep -v ${SELF}) + +TARGET_FOLDER="../../.git/hooks" +SCRIPT_FOLDER="../../scripts/git-hooks" + +if [ ! -d ${TARGET_FOLDER} ]; then + exit 2 +fi + +for f in ${FILES}; do + ln -sf ${SCRIPT_FOLDER}/${f} ${TARGET_FOLDER}/${f} +done diff --git a/scripts/git-hooks/post-commit b/scripts/git-hooks/post-commit new file mode 100755 index 0000000..882b3c2 --- /dev/null +++ b/scripts/git-hooks/post-commit @@ -0,0 +1,14 @@ +# +# Create docs after each commit +# + +# Load config options: +# - DPDK_GITHOOK_DOC_OUT +. scripts/load-devel-config.sh +if [ -n "$DPDK_GITHOOK_DOC_OUT" ]; then + OUT_CMD="O=${DPDK_GITHOOK_DOC_OUT}" +fi + +echo "Generating documents ..." +make ${OUT_CMD} doc-guides-html > /dev/null +make ${OUT_CMD} doc-api-html > /dev/null diff --git a/scripts/git-hooks/post-merge b/scripts/git-hooks/post-merge new file mode 120000 index 0000000..ace4560 --- /dev/null +++ b/scripts/git-hooks/post-merge @@ -0,0 +1 @@ +post-commit \ No newline at end of file diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit new file mode 100755 index 0000000..f3d6be4 --- /dev/null +++ b/scripts/git-hooks/pre-commit @@ -0,0 +1,13 @@ +# +# Check patch with checkpatch script before commit +# +# If checkpatch fails, commit fails +# +# Relies on scripts/checkpathes.sh script as checkpatch.pl wrapper +# +# It is skipped with the option "--no-verify" of "git commit". +# + +RTE_CHECKPATCH=$PWD/scripts/checkpatches.sh + +exec git diff --cached | ${RTE_CHECKPATCH} -- 2.5.0