DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
@ 2015-10-29 23:22 Ferruh Yigit
  2015-11-06 13:48 ` Ferruh Yigit
  2015-11-27 14:34 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
  0 siblings, 2 replies; 10+ messages in thread
From: Ferruh Yigit @ 2015-10-29 23:22 UTC (permalink / raw)
  To: dev

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. If script
finds any error it will print warnings and fails. If  checkpatch
fails commit also fails. This guaranties every commit pass checkpatch.
Default script is <dpdk>/scripts/checkpatch.pl but this can be
changed by RTE_CHECKPATCH environment variable. Also a default list
of checkpatch ignore items defined, new ones can be added by IGNORE
environment variable.
This script can bypassed by commit "--no-verify" argument.

Deployment:
To make scripts active they need to be in <dpdk>/.git/hooks folder.
Alternatively "deploy.sh" script can be used, it simply copies all
scripts into proper folder. Script names are significant and
shouldn't changed.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 scripts/git-hooks/deploy.sh   | 19 +++++++++++++++++++
 scripts/git-hooks/post-commit | 10 ++++++++++
 scripts/git-hooks/post-merge  | 10 ++++++++++
 scripts/git-hooks/pre-commit  | 44 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+)
 create mode 100755 scripts/git-hooks/deploy.sh
 create mode 100755 scripts/git-hooks/post-commit
 create mode 100755 scripts/git-hooks/post-merge
 create mode 100755 scripts/git-hooks/pre-commit

diff --git a/scripts/git-hooks/deploy.sh b/scripts/git-hooks/deploy.sh
new file mode 100755
index 0000000..0aa7ffb
--- /dev/null
+++ b/scripts/git-hooks/deploy.sh
@@ -0,0 +1,19 @@
+
+NAME=$(basename $0)
+
+if [ ! -f ${NAME} ]; then
+	echo "Please run script from folder where script is"
+	exit 1
+fi
+
+FILES=$(ls | grep -v ${NAME})
+
+TARGET_FOLDER="../../.git/hooks"
+
+if [ ! -d ${TARGET_FOLDER} ]; then
+	exit 2
+fi
+
+for f in ${FILES}; do
+	cp -i ${f} ${TARGET_FOLDER}/
+done;
diff --git a/scripts/git-hooks/post-commit b/scripts/git-hooks/post-commit
new file mode 100755
index 0000000..2a76f96
--- /dev/null
+++ b/scripts/git-hooks/post-commit
@@ -0,0 +1,10 @@
+#
+# Create docs after each commit
+#
+
+if [ -n "$RTE_DOC_OUT" ]; then
+	OUT_CMD="O=${RTE_DOC_OUT}"
+fi
+
+make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
+make ${OUT_CMD} doc-api-html 2>&1 > /dev/null
diff --git a/scripts/git-hooks/post-merge b/scripts/git-hooks/post-merge
new file mode 100755
index 0000000..2a76f96
--- /dev/null
+++ b/scripts/git-hooks/post-merge
@@ -0,0 +1,10 @@
+#
+# Create docs after each commit
+#
+
+if [ -n "$RTE_DOC_OUT" ]; then
+	OUT_CMD="O=${RTE_DOC_OUT}"
+fi
+
+make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
+make ${OUT_CMD} doc-api-html 2>&1 > /dev/null
diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit
new file mode 100755
index 0000000..102be73
--- /dev/null
+++ b/scripts/git-hooks/pre-commit
@@ -0,0 +1,44 @@
+#
+# Check patch with checkpatch script before commit
+#
+# If checkpatch fails, commit fails
+#
+# Sample command line can be like:
+# IGNORE="LINUX_VERSION_CODE,VOLATILE" RTE_CHACKPATCH=/linux/scripts/checkpatch.pl git commit
+#
+
+if [ -z "$RTE_CHECKPATCH" ]; then
+	RTE_CHECKPATCH=$PWD/scripts/checkpatch.pl
+fi
+
+if [ ! -x ${RTE_CHECKPATCH} ]; then
+	if [ -f ${RTE_CHECKPATCH} ]; then
+		echo "checkpatch script is not executable: ${RTE_CHECKPATCH}"
+	else
+		echo "checkpatch script not found: ${RTE_CHECKPATCH}"
+	fi
+	exit 2
+fi
+
+IGNORE_DEFAULT="LINUX_VERSION_CODE,\
+FILE_PATH_CHANGES,\
+VOLATILE,\
+PREFER_PACKED,\
+PREFER_ALIGNED,\
+PREFER_PRINTF,\
+PREFER_KERNEL_TYPES,\
+SPLIT_STRING,\
+LINE_SPACING,\
+PARENTHESIS_ALIGNMENT,\
+NETWORKING_BLOCK_COMMENT_STYLE,\
+NEW_TYPEDEFS,\
+COMPLEX_MACRO,\
+COMPARISON_TO_NULL"
+
+IGNORE_CMD="--ignore ${IGNORE_DEFAULT}"
+
+if [ -n "$IGNORE" ]; then
+	IGNORE_CMD="${IGNORE_CMD},${IGNORE}"
+fi
+
+exec git diff --cached | $RTE_CHECKPATCH ${IGNORE_CMD} --no-tree -q -
-- 
1.9.3

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-10-29 23:22 [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation Ferruh Yigit
@ 2015-11-06 13:48 ` Ferruh Yigit
  2015-11-06 13:48   ` Ferruh Yigit
  2015-11-06 14:03   ` Ferruh Yigit
  2015-11-27 14:34 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
  1 sibling, 2 replies; 10+ messages in thread
From: Ferruh Yigit @ 2015-11-06 13:48 UTC (permalink / raw)
  To: dev

Sorry for duplication, previous patch is not in the patchwork, this is the
exact same patch and re-sent for patchwork.

Ferruh Yigit (1):
  scripts: add git hook scripts for checkpatch and auto doc generation

 scripts/git-hooks/deploy.sh   | 19 +++++++++++++++++++
 scripts/git-hooks/post-commit | 10 ++++++++++
 scripts/git-hooks/post-merge  | 10 ++++++++++
 scripts/git-hooks/pre-commit  | 44 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+)
 create mode 100755 scripts/git-hooks/deploy.sh
 create mode 100755 scripts/git-hooks/post-commit
 create mode 100755 scripts/git-hooks/post-merge
 create mode 100755 scripts/git-hooks/pre-commit

-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-11-06 13:48 ` Ferruh Yigit
@ 2015-11-06 13:48   ` Ferruh Yigit
  2015-11-24 17:44     ` Thomas Monjalon
  2015-11-06 14:03   ` Ferruh Yigit
  1 sibling, 1 reply; 10+ messages in thread
From: Ferruh Yigit @ 2015-11-06 13:48 UTC (permalink / raw)
  To: dev

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. If script
finds any error it will print warnings and fails. If  checkpatch
fails commit also fails. This guaranties every commit pass checkpatch.
Default script is <dpdk>/scripts/checkpatch.pl but this can be
changed by RTE_CHECKPATCH environment variable. Also a default list
of checkpatch ignore items defined, new ones can be added by IGNORE
environment variable.
This script can bypassed by commit "--no-verify" argument.

Deployment:
To make scripts active they need to be in <dpdk>/.git/hooks folder.
Alternatively "deploy.sh" script can be used, it simply copies all
scripts into proper folder. Script names are significant and
shouldn't changed.

Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
---
 scripts/git-hooks/deploy.sh   | 19 +++++++++++++++++++
 scripts/git-hooks/post-commit | 10 ++++++++++
 scripts/git-hooks/post-merge  | 10 ++++++++++
 scripts/git-hooks/pre-commit  | 44 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+)
 create mode 100755 scripts/git-hooks/deploy.sh
 create mode 100755 scripts/git-hooks/post-commit
 create mode 100755 scripts/git-hooks/post-merge
 create mode 100755 scripts/git-hooks/pre-commit

diff --git a/scripts/git-hooks/deploy.sh b/scripts/git-hooks/deploy.sh
new file mode 100755
index 0000000..0aa7ffb
--- /dev/null
+++ b/scripts/git-hooks/deploy.sh
@@ -0,0 +1,19 @@
+
+NAME=$(basename $0)
+
+if [ ! -f ${NAME} ]; then
+	echo "Please run script from folder where script is"
+	exit 1
+fi
+
+FILES=$(ls | grep -v ${NAME})
+
+TARGET_FOLDER="../../.git/hooks"
+
+if [ ! -d ${TARGET_FOLDER} ]; then
+	exit 2
+fi
+
+for f in ${FILES}; do
+	cp -i ${f} ${TARGET_FOLDER}/
+done;
diff --git a/scripts/git-hooks/post-commit b/scripts/git-hooks/post-commit
new file mode 100755
index 0000000..2a76f96
--- /dev/null
+++ b/scripts/git-hooks/post-commit
@@ -0,0 +1,10 @@
+#
+# Create docs after each commit
+#
+
+if [ -n "$RTE_DOC_OUT" ]; then
+	OUT_CMD="O=${RTE_DOC_OUT}"
+fi
+
+make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
+make ${OUT_CMD} doc-api-html 2>&1 > /dev/null
diff --git a/scripts/git-hooks/post-merge b/scripts/git-hooks/post-merge
new file mode 100755
index 0000000..2a76f96
--- /dev/null
+++ b/scripts/git-hooks/post-merge
@@ -0,0 +1,10 @@
+#
+# Create docs after each commit
+#
+
+if [ -n "$RTE_DOC_OUT" ]; then
+	OUT_CMD="O=${RTE_DOC_OUT}"
+fi
+
+make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
+make ${OUT_CMD} doc-api-html 2>&1 > /dev/null
diff --git a/scripts/git-hooks/pre-commit b/scripts/git-hooks/pre-commit
new file mode 100755
index 0000000..102be73
--- /dev/null
+++ b/scripts/git-hooks/pre-commit
@@ -0,0 +1,44 @@
+#
+# Check patch with checkpatch script before commit
+#
+# If checkpatch fails, commit fails
+#
+# Sample command line can be like:
+# IGNORE="LINUX_VERSION_CODE,VOLATILE" RTE_CHACKPATCH=/linux/scripts/checkpatch.pl git commit
+#
+
+if [ -z "$RTE_CHECKPATCH" ]; then
+	RTE_CHECKPATCH=$PWD/scripts/checkpatch.pl
+fi
+
+if [ ! -x ${RTE_CHECKPATCH} ]; then
+	if [ -f ${RTE_CHECKPATCH} ]; then
+		echo "checkpatch script is not executable: ${RTE_CHECKPATCH}"
+	else
+		echo "checkpatch script not found: ${RTE_CHECKPATCH}"
+	fi
+	exit 2
+fi
+
+IGNORE_DEFAULT="LINUX_VERSION_CODE,\
+FILE_PATH_CHANGES,\
+VOLATILE,\
+PREFER_PACKED,\
+PREFER_ALIGNED,\
+PREFER_PRINTF,\
+PREFER_KERNEL_TYPES,\
+SPLIT_STRING,\
+LINE_SPACING,\
+PARENTHESIS_ALIGNMENT,\
+NETWORKING_BLOCK_COMMENT_STYLE,\
+NEW_TYPEDEFS,\
+COMPLEX_MACRO,\
+COMPARISON_TO_NULL"
+
+IGNORE_CMD="--ignore ${IGNORE_DEFAULT}"
+
+if [ -n "$IGNORE" ]; then
+	IGNORE_CMD="${IGNORE_CMD},${IGNORE}"
+fi
+
+exec git diff --cached | $RTE_CHECKPATCH ${IGNORE_CMD} --no-tree -q -
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-11-06 13:48 ` Ferruh Yigit
  2015-11-06 13:48   ` Ferruh Yigit
@ 2015-11-06 14:03   ` Ferruh Yigit
  1 sibling, 0 replies; 10+ messages in thread
From: Ferruh Yigit @ 2015-11-06 14:03 UTC (permalink / raw)
  To: dev

On Fri, Nov 06, 2015 at 01:48:51PM +0000, Ferruh Yigit wrote:
> Sorry for duplication, previous patch is not in the patchwork, this is the
> exact same patch and re-sent for patchwork.
> 
Incase anybody interested patchwork error seems because of a special char in message header "Received" field.
Failed ones has: "... with œ id ..."

Not sure why specific host appends this char.

Thanks,
ferruh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-11-06 13:48   ` Ferruh Yigit
@ 2015-11-24 17:44     ` Thomas Monjalon
  2015-11-24 18:04       ` Ferruh Yigit
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2015-11-24 17:44 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

Thanks for the idea

2015-11-06 13:48, Ferruh Yigit:
> post-merge: Same script as "post-commit", but triggered after git pull

A symbolic link would be sufficient.
As it must be installed in the git hooks (probably making a symbolic link),
duplicating the file is not needed at all.

> pre-commit: Does a checkpatch check before commit started. If script
> finds any error it will print warnings and fails. If  checkpatch
> fails commit also fails. This guaranties every commit pass checkpatch.
> Default script is <dpdk>/scripts/checkpatch.pl but this can be
> changed by RTE_CHECKPATCH environment variable. Also a default list
> of checkpatch ignore items defined, new ones can be added by IGNORE
> environment variable.

Please use the new scripts/checkpatches.sh:
http://dpdk.org/dev/patchwork/patch/9036/

> This script can bypassed by commit "--no-verify" argument.

Could you document the --no-verify option in the script?

> Deployment:
> To make scripts active they need to be in <dpdk>/.git/hooks folder.
> Alternatively "deploy.sh" script can be used, it simply copies all
> scripts into proper folder. Script names are significant and
> shouldn't changed.

Why not using symbolic links?

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-11-24 17:44     ` Thomas Monjalon
@ 2015-11-24 18:04       ` Ferruh Yigit
  0 siblings, 0 replies; 10+ messages in thread
From: Ferruh Yigit @ 2015-11-24 18:04 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Tue, Nov 24, 2015 at 06:44:36PM +0100, Thomas Monjalon wrote:
> Thanks for the idea
> 
> 2015-11-06 13:48, Ferruh Yigit:
> > post-merge: Same script as "post-commit", but triggered after git pull
> 
> A symbolic link would be sufficient.
> As it must be installed in the git hooks (probably making a symbolic link),
> duplicating the file is not needed at all.
> 
OK

> > pre-commit: Does a checkpatch check before commit started. If script
> > finds any error it will print warnings and fails. If  checkpatch
> > fails commit also fails. This guaranties every commit pass checkpatch.
> > Default script is <dpdk>/scripts/checkpatch.pl but this can be
> > changed by RTE_CHECKPATCH environment variable. Also a default list
> > of checkpatch ignore items defined, new ones can be added by IGNORE
> > environment variable.
> 
> Please use the new scripts/checkpatches.sh:
> http://dpdk.org/dev/patchwork/patch/9036/
> 
OK, better to use that script, to prevent duplicated IGNORE flag and checkpatch.pl location maintenance.

> > This script can bypassed by commit "--no-verify" argument.
> 
> Could you document the --no-verify option in the script?
> 
This is git feature, with that flag script not called at all, I will add this comment into script.

> > Deployment:
> > To make scripts active they need to be in <dpdk>/.git/hooks folder.
> > Alternatively "deploy.sh" script can be used, it simply copies all
> > scripts into proper folder. Script names are significant and
> > shouldn't changed.
> 
> Why not using symbolic links?
> 
Yes we can use symbolic links.

I will send updated patch.

Thanks for the review,
ferruh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v2] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-10-29 23:22 [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation Ferruh Yigit
  2015-11-06 13:48 ` Ferruh Yigit
@ 2015-11-27 14:34 ` Ferruh Yigit
  2015-12-03 19:09   ` Thomas Monjalon
  1 sibling, 1 reply; 10+ messages in thread
From: Ferruh Yigit @ 2015-11-27 14:34 UTC (permalink / raw)
  To: dev

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 <dpdk>/.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 <ferruh.yigit@intel.com>
---
 scripts/checkpatches.sh       |  1 +
 scripts/git-hooks/deploy.sh   | 20 ++++++++++++++++++++
 scripts/git-hooks/post-commit | 10 ++++++++++
 scripts/git-hooks/post-merge  |  1 +
 scripts/git-hooks/pre-commit  | 17 +++++++++++++++++
 5 files changed, 49 insertions(+)
 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/scripts/checkpatches.sh b/scripts/checkpatches.sh
index afc611b..8192514 100755
--- a/scripts/checkpatches.sh
+++ b/scripts/checkpatches.sh
@@ -43,6 +43,7 @@ length=${DPDK_CHECKPATCH_LINE_LENGTH:-80}
 
 # override default Linux options
 options="--no-tree"
+options="$options ${GIT_HOOK_OPTIONS}"
 options="$options --max-line-length=$length"
 options="$options --show-types"
 options="$options --ignore=LINUX_VERSION_CODE,FILE_PATH_CHANGES,\
diff --git a/scripts/git-hooks/deploy.sh b/scripts/git-hooks/deploy.sh
new file mode 100755
index 0000000..070fb6e
--- /dev/null
+++ b/scripts/git-hooks/deploy.sh
@@ -0,0 +1,20 @@
+
+SELF=$(basename $0)
+
+if [ ! -f ${SELF} ]; then
+	echo "Please run script from folder where script is"
+	exit 1
+fi
+
+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..2a76f96
--- /dev/null
+++ b/scripts/git-hooks/post-commit
@@ -0,0 +1,10 @@
+#
+# Create docs after each commit
+#
+
+if [ -n "$RTE_DOC_OUT" ]; then
+	OUT_CMD="O=${RTE_DOC_OUT}"
+fi
+
+make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
+make ${OUT_CMD} doc-api-html 2>&1 > /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..c46b27d
--- /dev/null
+++ b/scripts/git-hooks/pre-commit
@@ -0,0 +1,17 @@
+#
+# Check patch with checkpatch script before commit
+#
+# If checkpatch fails, commit fails
+#
+# Relies on scripts/checkpathes.sh script as checkpatch.pl wrapper
+#
+# If "git commit" called with "--no-verify" option, pre-commit hooks
+# bypassed and this script not called, checkpatch bypassed
+#
+
+RTE_CHECKPATCH=$PWD/scripts/checkpatches.sh
+PATCH=/tmp/dpdk-git-auto-checkpatch-$$.patch
+export GIT_HOOK_OPTIONS=--no-signoff
+
+git diff --cached > ${PATCH}
+exec ${RTE_CHECKPATCH} ${PATCH}
-- 
2.5.0

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-11-27 14:34 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
@ 2015-12-03 19:09   ` Thomas Monjalon
  2015-12-07 13:32     ` Ferruh Yigit
  0 siblings, 1 reply; 10+ messages in thread
From: Thomas Monjalon @ 2015-12-03 19:09 UTC (permalink / raw)
  To: Ferruh Yigit; +Cc: dev

Ferruh,
I have a lot of questions :)

2015-11-27 14:34, Ferruh Yigit:
> --- a/scripts/checkpatches.sh
> +++ b/scripts/checkpatches.sh
> @@ -43,6 +43,7 @@ length=${DPDK_CHECKPATCH_LINE_LENGTH:-80}
>  
>  # override default Linux options
>  options="--no-tree"
> +options="$options ${GIT_HOOK_OPTIONS}"

What is the purpose of this variable?
Why adding some options would be specific to git hooks?

> +++ b/scripts/git-hooks/deploy.sh
> @@ -0,0 +1,20 @@
> +
> +SELF=$(basename $0)
> +
> +if [ ! -f ${SELF} ]; then
> +	echo "Please run script from folder where script is"
> +	exit 1
> +fi

You do not need to exit. Just cd $(dirname $0).

> +for f in ${FILES}; do
> +	ln -sf ${SCRIPT_FOLDER}/${f} ${TARGET_FOLDER}/${f}
> +done;

You do not need the ;

> --- /dev/null
> +++ b/scripts/git-hooks/post-commit
> +if [ -n "$RTE_DOC_OUT" ]; then
> +	OUT_CMD="O=${RTE_DOC_OUT}"
> +fi

How to pass RTE_DOC_OUT to the hook?
Why not use load-devel-config.sh?

> +make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
> +make ${OUT_CMD} doc-api-html 2>&1 > /dev/null

Why hiding the errors?

> --- /dev/null
> +++ b/scripts/git-hooks/post-merge

Does it work for "git pull --rebase"?

> --- /dev/null
> +++ b/scripts/git-hooks/pre-commit
> +# If "git commit" called with "--no-verify" option, pre-commit hooks
> +# bypassed and this script not called, checkpatch bypassed

Possible reword: It is skipped with the option "--no-verify" of "git commit".

> +RTE_CHECKPATCH=$PWD/scripts/checkpatches.sh

What is PWD when calling the hook. May it be a subdir?

> +PATCH=/tmp/dpdk-git-auto-checkpatch-$$.patch

You need to remove this temporary file when exiting.
But it would be better to use stdin.
It may need a patch on checkpatches.sh wrapper.
In chekpatch.pl: "When FILE is - read standard input".

> +export GIT_HOOK_OPTIONS=--no-signoff

This variable is wrongly named.

> +git diff --cached > ${PATCH}
> +exec ${RTE_CHECKPATCH} ${PATCH}

When the new "make install" will be applied, I think we should skip
these files. Please consider patching mk/rte.sdkinstall.mk.
Thanks

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [dpdk-dev] [PATCH v2] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-12-03 19:09   ` Thomas Monjalon
@ 2015-12-07 13:32     ` Ferruh Yigit
  2015-12-07 15:06       ` [dpdk-dev] [PATCH v3] " Ferruh Yigit
  0 siblings, 1 reply; 10+ messages in thread
From: Ferruh Yigit @ 2015-12-07 13:32 UTC (permalink / raw)
  To: Thomas Monjalon; +Cc: dev

On Thu, Dec 03, 2015 at 11:09:30AM -0800, Thomas Monjalon wrote:
> Ferruh,
> I have a lot of questions :)
> 
> 2015-11-27 14:34, Ferruh Yigit:
> > --- a/scripts/checkpatches.sh
> > +++ b/scripts/checkpatches.sh
> > @@ -43,6 +43,7 @@ length=${DPDK_CHECKPATCH_LINE_LENGTH:-80}
> >  
> >  # override default Linux options
> >  options="--no-tree"
> > +options="$options ${GIT_HOOK_OPTIONS}"
> 
> What is the purpose of this variable?
> Why adding some options would be specific to git hooks?
> 
When you use "commit -s", sign-off msg added after this script run,
also when you do "commit --ammend" that piece of patch does not have sign-off part,
so pre-commit hook can have problems with sign-off check and git hook specific option is to pass --no-signoff option.

> > +++ b/scripts/git-hooks/deploy.sh
> > @@ -0,0 +1,20 @@
> > +
> > +SELF=$(basename $0)
> > +
> > +if [ ! -f ${SELF} ]; then
> > +	echo "Please run script from folder where script is"
> > +	exit 1
> > +fi
> 
> You do not need to exit. Just cd $(dirname $0).
> 
Thanks, I will do that.


> > +for f in ${FILES}; do
> > +	ln -sf ${SCRIPT_FOLDER}/${f} ${TARGET_FOLDER}/${f}
> > +done;
> 
> You do not need the ;
> 
OK

> > --- /dev/null
> > +++ b/scripts/git-hooks/post-commit
> > +if [ -n "$RTE_DOC_OUT" ]; then
> > +	OUT_CMD="O=${RTE_DOC_OUT}"
> > +fi
> 
> How to pass RTE_DOC_OUT to the hook?
> Why not use load-devel-config.sh?
> 
It is possbile pass by exporting it as environment variable,
but since load-devel-config is already there, I will use it.

> > +make ${OUT_CMD} doc-guides-html 2>&1 > /dev/null
> > +make ${OUT_CMD} doc-api-html 2>&1 > /dev/null
> 
> Why hiding the errors?
> 
To prevent noise, but I double check and enabling error messages not noisy, so I will enable it.

> > --- /dev/null
> > +++ b/scripts/git-hooks/post-merge
> 
> Does it work for "git pull --rebase"?

No, it is not working, for that pre-rebase is required,
easy to create a link for that but I am not sure about increasing number of hooks,
with pre-rebase hook, an internal rebase too will trigger doc generation, which is not good I believe.

> 
> > --- /dev/null
> > +++ b/scripts/git-hooks/pre-commit
> > +# If "git commit" called with "--no-verify" option, pre-commit hooks
> > +# bypassed and this script not called, checkpatch bypassed
> 
> Possible reword: It is skipped with the option "--no-verify" of "git commit".
> 
OK, thanks.

> > +RTE_CHECKPATCH=$PWD/scripts/checkpatches.sh
> 
> What is PWD when calling the hook. May it be a subdir?
> 
Even you call git commands from a subdir, git hooks scripts run from root dir, so this will be always correct.


> > +PATCH=/tmp/dpdk-git-auto-checkpatch-$$.patch
> 
> You need to remove this temporary file when exiting.
> But it would be better to use stdin.
> It may need a patch on checkpatches.sh wrapper.
> In chekpatch.pl: "When FILE is - read standard input".
> 
I also prefer using stdin, and previous patch was like that,
but checkpatches.sh requires a file, let me check possible update in checkpatches.sh

> > +export GIT_HOOK_OPTIONS=--no-signoff
> 
> This variable is wrongly named.
> 
Will rename.

> > +git diff --cached > ${PATCH}
> > +exec ${RTE_CHECKPATCH} ${PATCH}
> 
> When the new "make install" will be applied, I think we should skip
> these files. Please consider patching mk/rte.sdkinstall.mk.

ok, I will update skdinstall.mk


Thanks for the review.

ferruh

^ permalink raw reply	[flat|nested] 10+ messages in thread

* [dpdk-dev] [PATCH v3] scripts: add git hook scripts for checkpatch and auto doc generation
  2015-12-07 13:32     ` Ferruh Yigit
@ 2015-12-07 15:06       ` Ferruh Yigit
  0 siblings, 0 replies; 10+ messages in thread
From: Ferruh Yigit @ 2015-12-07 15:06 UTC (permalink / raw)
  To: dev

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 <dpdk>/.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 <ferruh.yigit@intel.com>
---
 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

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-12-07 15:06 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-10-29 23:22 [dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation Ferruh Yigit
2015-11-06 13:48 ` Ferruh Yigit
2015-11-06 13:48   ` Ferruh Yigit
2015-11-24 17:44     ` Thomas Monjalon
2015-11-24 18:04       ` Ferruh Yigit
2015-11-06 14:03   ` Ferruh Yigit
2015-11-27 14:34 ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2015-12-03 19:09   ` Thomas Monjalon
2015-12-07 13:32     ` Ferruh Yigit
2015-12-07 15:06       ` [dpdk-dev] [PATCH v3] " Ferruh Yigit

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).