topdir.mk: Derive GITIGNORE_PATTERNS_END from TOP #136

Merged
Jan Lindemann merged 1 commit from jan/feature/20261003-topdir-mk-derive-gitignore-patterns-end-from-top into master 2026-10-03 16:02:11 +02:00 AGit
Showing only changes of commit ce3045e081 - Show all commits

topdir.mk: Derive GITIGNORE_PATTERNS_END from TOP
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 5m31s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m47s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m55s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m35s
CI / Packaging test (push) Successful in 0s

The !-exceptions in the generated .gitignore are computed by a grep pattern
that hardcodes the project name, while the top ignore line comes from
GITIGNORE_PATTERNS_TOP. A project that overrides GITIGNORE_PATTERNS_TOP -
jw-pkg's Makefile sets it to empty - still gets the hardcoded exceptions,
and patterns a project adds there get no exceptions at all, so the two can
drift apart.

Derive the exception pattern from the same variable:

- new GITIGNORE_PATTERNS_TOP_INV joins the patterns of
  GITIGNORE_PATTERNS_TOP with |, each wrapped in word boundaries, plus the
  __init__.py pattern
- GITIGNORE_PATTERNS_END greps the tracked files for that alternation with
  grep -E instead of a hardcoded BRE, so the dot in __init__.py is literal
  instead of matching any character

With the default GITIGNORE_PATTERNS_TOP the generated .gitignore is
byte-for-byte identical to before.

Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.0.0
Signed-off-by: Jan Lindemann <jan@janware.com>
Jan Lindemann 2026-10-03 15:49:17 +02:00
Signed by: Jan Lindemann
GPG key ID: 3750640C9E25DD61

View file

@ -98,7 +98,8 @@ JW_PKG_TMPL_UPDATE ?= $(PYTHON) $(JWB_SCRIPT_DIR)/jw-pkg.py -p $(PROJEC
projects create-file --format tmpl --search-path $(subst $(space),:,$(JW_PKG_TMPL_SEARCH_PATH)) --template-name projects create-file --format tmpl --search-path $(subst $(space),:,$(JW_PKG_TMPL_SEARCH_PATH)) --template-name
GITIGNORE_PATTERNS_TOP ?= $(PROJECT) GITIGNORE_PATTERNS_TOP ?= $(PROJECT)
GITIGNORE_PATTERNS_END ?= $(addprefix !,$(shell git ls-files 2>/dev/null | grep "\(\b$(PROJECT)\b\|__init__.py\)" | xargs)) GITIGNORE_PATTERNS_TOP_INV ?= $(subst $(space),|,$(strip $(addprefix \b,$(addsuffix \b,$(GITIGNORE_PATTERNS_TOP))) __init__\.py))
GITIGNORE_PATTERNS_END ?= $(addprefix !,$(shell git ls-files 2>/dev/null | grep -E "($(GITIGNORE_PATTERNS_TOP_INV))" | xargs))
all: topdir config all: topdir config
test: all test: all