From 18657caf8d5c5388190b29c0cc1b4b94c997d5dc Mon Sep 17 00:00:00 2001 From: Michael Mann Date: Sat, 25 Nov 2017 14:18:06 -0500 Subject: [PATCH] Add information about pre-commit script to Developer Guide. Bug: 9553 Change-Id: I19505c3c05585a05877e9f0db06400ebb8b33985 Reviewed-on: https://code.wireshark.org/review/24585 Reviewed-by: Michael Mann --- .../wsdg_src/WSDG_chapter_sources.asciidoc | 24 +++++++++++++++---- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/docbook/wsdg_src/WSDG_chapter_sources.asciidoc b/docbook/wsdg_src/WSDG_chapter_sources.asciidoc index c8a2a83c2f..2177c445ed 100644 --- a/docbook/wsdg_src/WSDG_chapter_sources.asciidoc +++ b/docbook/wsdg_src/WSDG_chapter_sources.asciidoc @@ -802,12 +802,26 @@ can easily be put into "the big pile", while some are ASN.1 based which takes a different approach, and some multiple source file dissectors are more suitable to be placed separately as plugins. -* 'Verify that your dissector code does not use prohibited or deprecated APIs.' - This can be done as follows: +* 'Ensure Wireshark Git Pre-Commit Hook is in the repository.' In your local +repository directory, there will be a .git/hooks/ directory, with sample git hooks +for running automatic actions before and after git commands. You can also +optionally install other hooks that you find useful. + ----- -$ perl /tools/checkAPIs.pl ----- +In particular, the pre-commit hook will run every time you commit a change and can +be used to automatically check for various errors in your code. The sample git +pre-commit hook simply detects whitespace errors such as mixed tabs and spaces; +to install it just remove the .sample suffice from the existing pre-commit.sample file. ++ +Wireshark provides a custom pre-commit hook which does additional Wireshark-specific API +and formatting checks, but it might return false positives. If you want to install it, +copy the pre-commit file from the tools directory (cp ./tools/pre-commit .git/hooks/) +and make sure it is executable or it will not be run. ++ +If the pre-commit hook is preventing you from committing what you believe is a valid +change, you can run git commit --no-verify to skip running the hooks. Warning: using +--no-verify avoids the commit-msg hook, and thus will not automatically add the required +Change-ID to your commit. In case you are not updating an existing patch you may generate +a Change-ID by running git review -i (or git commit --amend if don't use git review). * 'Fuzz test your changes!' Fuzz testing is a very effective way to automatically find a lot of dissector related bugs.