Re: [PATCH v5] send-email: export patch counters in validate environment
- From
Robin Jarry <robin@jarry.cc>
- Date
- Apr 20, 2023, 19:16 UTC
- Message-ID
- <CS1TOE1MCMH0.2OMA9UHSDG7RC@ringo>
- In-Reply-To
- <20230414155249.667180-1-robin@jarry.cc>
Robin Jarry, Apr 14, 2023 at 17:52:
Show 43 quoted lines
> diff --git a/templates/hooks--sendemail-validate.sample b/templates/hooks--sendemail-validate.sample
> new file mode 100755
> index 000000000000..ad2f9a86473d
> --- /dev/null
> +++ b/templates/hooks--sendemail-validate.sample
> @@ -0,0 +1,77 @@
> +#!/bin/sh
> +
> +# An example hook script to validate a patch (and/or patch series) before
> +# sending it via email.
> +#
> +# The hook should exit with non-zero status after issuing an appropriate
> +# message if it wants to prevent the email(s) from being sent.
> +#
> +# To enable this hook, rename this file to "sendemail-validate".
> +#
> +# By default, it will only check that the patch(es) can be applied on top of
> +# the default upstream branch without conflicts in a secondary worktree. After
> +# validation (successful or not) of the last patch of a series, the worktree
> +# will be deleted.
> +#
> +# The following config variables can be set to change the default remote and
> +# remote ref that are used to apply the patches against:
> +#
> +# sendemail.validateRemote (default: origin)
> +# sendemail.validateRemoteRef (default: HEAD)
> +#
> +# Replace the TODO placeholders with appropriate checks according to your
> +# needs.
> +
> +validate_cover_letter() {
> + file="$1"
> + # TODO: Replace with appropriate checks (e.g. spell checking).
> + true
> +}
> +
> +validate_patch() {
> + file="$1"
> + # Ensure that the patch applies without conflicts.
> + git am -3 "$file" || return
> + # TODO: Replace with appropriate checks for this patch
> + # (e.g. checkpatch.pl).
> + trueHey folks,
I had an idea after sending v5. Instead of leaving TODO placeholders, it would be nicer to introduce other git config sendemail.validate* options specific to this hook template so that users can directly use it without any modifications simply by setting options in their local clone:
git config sendemail.validatePatchCmd 'tools/checkpatch.sh'
git config sendemail.validateSeriesCmd 'make tests lint'And reuse these commands if defined in the hook template.
What do you think?