~rjarry/aerc-devel

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
3 3

[PATCH aerc] use grep -E for commit-msg hook

Maarten Aertsen <maarten@nlnetlabs.nl>
Details
Message ID
<20240226205658.9375-1-maarten@nlnetlabs.nl>
DKIM signature
pass
Download raw message
Patch: +2 -2
The + character is not part of the 'basic regular expressions' in BSD
grep. We now use -E to use extended (modern) regular expressions. Also
remove escaping. This makes the commit msg hook work on macOS 14.2.

Signed-off-by: Maarten Aertsen <maarten@nlnetlabs.nl>
---
 contrib/commit-msg | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/contrib/commit-msg b/contrib/commit-msg
index add67177..503b5a11 100755
--- a/contrib/commit-msg
+++ b/contrib/commit-msg
@@ -41,7 +41,7 @@ while read -r key value; do
	key="$first_letter$other_letters"

	# Find sort order of this key.
	order=$(echo "$trailer_order" | grep -Fxn "$key" | sed -n 's/^\([0-9]\+\):.*/\1/p')
	order=$(echo "$trailer_order" | grep -Fxn "$key" | sed -nE 's/^([0-9]+):.*/\1/p')
	if [ -z "$order" ]; then
		echo "warning: unknown trailer '$key'" >&2
		# Unknown trailers are always first.
@@ -51,7 +51,7 @@ while read -r key value; do
	echo "$order $key $value"
done |
# Sort trailers according to their numeric order, trim the numeric order.
LC_ALL=C sort -n | sed 's/^[0-9]\+ //' > "$tmp"
LC_ALL=C sort -n | sed -E 's/^[0-9]+ //' > "$tmp"

debug echo ==== sanitized trailers ====
debug cat "$tmp"
-- 
2.39.3 (Apple Git-145)

[aerc/patches] build failed

builds.sr.ht <builds@sr.ht>
Details
Message ID
<CZFBAGLU74UD.R7JD66SAJR1S@fra02>
In-Reply-To
<20240226205658.9375-1-maarten@nlnetlabs.nl> (view parent)
DKIM signature
missing
Download raw message
aerc/patches: FAILED in 2m12s

[use grep -E for commit-msg hook][0] from [Maarten Aertsen][1]

[0]: https://lists.sr.ht/~rjarry/aerc-devel/patches/49816
[1]: maarten@nlnetlabs.nl

✓ #1157742 SUCCESS aerc/patches/openbsd.yml     https://builds.sr.ht/~rjarry/job/1157742
✗ #1157741 FAILED  aerc/patches/alpine-edge.yml https://builds.sr.ht/~rjarry/job/1157741
Details
Message ID
<CZFBCS1ZMOGP.2PXDCX54QB735@ringo>
In-Reply-To
<20240226205658.9375-1-maarten@nlnetlabs.nl> (view parent)
DKIM signature
pass
Download raw message
Maarten Aertsen, Feb 26, 2024 at 21:58:
> The + character is not part of the 'basic regular expressions' in BSD
> grep. We now use -E to use extended (modern) regular expressions. Also
> remove escaping. This makes the commit msg hook work on macOS 14.2.
>
> Signed-off-by: Maarten Aertsen <maarten@nlnetlabs.nl>

Hi Maarten,

thanks and congrats on your first patch. To make the linter happy, can 
you change the title of the commit to:

    contrib: use sed -E for commit-msg hook

The patch itself is fine :)

Thanks!
Details
Message ID
<CZFBE69FZMBO.3CQZJD8HKULR5@cepl.eu>
In-Reply-To
<20240226205658.9375-1-maarten@nlnetlabs.nl> (view parent)
DKIM signature
missing
Download raw message
On Mon Feb 26, 2024 at 9:56 PM CET, Maarten Aertsen wrote:
>  	# Find sort order of this key.
> -	order=$(echo "$trailer_order" | grep -Fxn "$key" | sed -n 's/^\([0-9]\+\):.*/\1/p')
> +	order=$(echo "$trailer_order" | grep -Fxn "$key" | sed -nE 's/^([0-9]+):.*/\1/p')

A nit … the change is in sed(1) not in grep(1). Also, whenever I
see a combination of grep and sed, my first question is “Wouldn’t
awk(1) work here better?”

Best,

Matěj

-- 
http://matej.ceplovi.cz/blog/, @mcepl@floss.social
GPG Finger: 3C76 A027 CA45 AD70 98B5  BC1D 7920 5802 880B C9D8
 
Afraid to die alone?
Become a bus driver.
  -- alleged easter egg in notepad++
Reply to thread Export thread (mbox)