Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -366,10 +366,14 @@ def grep_comment_candidates(
noun_alt = "|".join(re.escape(n) for n in nouns)
anchor_alt = "|".join(re.escape(a) for a in anchors)
# A comment-leading line containing an anchor AND a content noun, in either
# order. ``git grep`` keeps the scan inside tracked files only.
# order. ``git grep`` keeps the scan inside tracked files only. Use the
# POSIX class ``[[:space:]]`` instead of ``\s``: ``\s`` is a GNU regex
# extension that git's ERE engine does not honor on macOS/BSD, so the
# pattern would silently match nothing there (and concept-anchoring would
# quietly disable itself).
pat = (
rf"^\s*(#|//|--|\*).*({anchor_alt}).*({noun_alt})"
rf"|^\s*(#|//|--|\*).*({noun_alt}).*({anchor_alt})"
rf"^[[:space:]]*(#|//|--|\*).*({anchor_alt}).*({noun_alt})"
rf"|^[[:space:]]*(#|//|--|\*).*({noun_alt}).*({anchor_alt})"
)
try:
proc = subprocess.run(
Expand All @@ -382,6 +386,10 @@ def grep_comment_candidates(
"git",
"--no-pager",
"grep",
# --no-color: this output is parsed, so a user's
# ``color.ui=always`` git config must not wrap paths in ANSI
# escapes (which would corrupt the path split below).
"--no-color",
"-n",
"-I",
"-i",
Expand Down
Loading