From 11574109a797f9ed0074fadb834dca404a5c6d24 Mon Sep 17 00:00:00 2001 From: Aurelio Jargas Date: Sat, 18 May 2024 01:06:34 +0200 Subject: [PATCH 1/2] Make pre-commit hook regex more precise In regular expressions, the dot `.` is a metachar that matches every char. To match the literal dot it must be escaped `\.`. Without the escape, that regex would match unintended filenames, such as `poetry-lock`, `poetry_lock`, `poetryblock`, `poetryclock` and other variations. --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index b7a3244..fe9ef80 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -5,5 +5,5 @@ language: python language_version: python3 pass_filenames: false - files: ^poetry.lock$ + files: ^poetry\.lock$ args: ["-f", "requirements.txt", "-o", "requirements.txt"] From 4b49a7eb3a8127057015bcbb2303d1fa27bc15ac Mon Sep 17 00:00:00 2001 From: Aurelio Jargas Date: Mon, 20 May 2024 21:23:55 +0200 Subject: [PATCH 2/2] Harmonize pre-commit hook regex with Poetry's MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now using the same regex as the one used in https://github.com/python-poetry/poetry/blob/25b3f6c2f4347286eb31b00f6e39126e57eac5a2/.pre-commit-hooks.yaml#L23 Co-authored-by: Randy Döring <30527984+radoering@users.noreply.github.com> --- .pre-commit-hooks.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-hooks.yaml b/.pre-commit-hooks.yaml index fe9ef80..238fc18 100644 --- a/.pre-commit-hooks.yaml +++ b/.pre-commit-hooks.yaml @@ -5,5 +5,5 @@ language: python language_version: python3 pass_filenames: false - files: ^poetry\.lock$ + files: ^(.*/)?poetry\.lock$ args: ["-f", "requirements.txt", "-o", "requirements.txt"]