[dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
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 /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 /.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?
[dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
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 /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 /.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
[dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
On Fri, Nov 06, 2015 at 01:48:51PM +, 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
[dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
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 /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 /.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 --- 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 000..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 000..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 000..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 000..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
[dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
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
[dpdk-dev] [PATCH] scripts: add git hook scripts for checkpatch and auto doc generation
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 /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 /.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 --- 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 000..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 000..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 000..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 000..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