Skip to content

Commit 2f34224

Browse files
paldepindCopilot
andcommitted
Fix query help previews for nested includes
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 048a2ae1-eefb-4da9-bfe1-33335c3707ed
1 parent d08eb2c commit 2f34224

2 files changed

Lines changed: 22 additions & 7 deletions

File tree

‎.github/workflows/qhelp-pr-preview.yml‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ jobs:
5151
- name: Determine changed files
5252
id: changes
5353
run: |
54-
(git diff -z --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep -z '.qhelp$' | grep -z -v '.inc.qhelp';
55-
git diff -z --name-only --diff-filter=ACMRT HEAD~1 HEAD | grep -z '.inc.qhelp$' | xargs --null -rn1 basename -z | xargs --null -rn1 git grep -z -l) |
56-
grep -z '.qhelp$' | grep -z -v '^-' | sort -z -u > "${RUNNER_TEMP}/paths.txt"
54+
git diff -z --name-only --diff-filter=ACMRT HEAD~1 HEAD -- '*.qhelp' |
55+
python3 misc/scripts/check-qhelp.py --list |
56+
sort -z -u > "${RUNNER_TEMP}/paths.txt"
5757
5858
- name: QHelp preview
5959
run: |

‎misc/scripts/check-qhelp.py‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
55
This takes care of:
66
* providing a temporary directory to --output
7-
* finding usages of .inc.qhelp arguments
7+
* finding direct and indirect usages of .inc.qhelp arguments
88
"""
99

10+
import os
1011
import pathlib
1112
import subprocess
1213
import sys
@@ -50,14 +51,28 @@ def find_inc_qhelp_usages(arg):
5051

5152

5253
def transform_inputs(args):
53-
for arg in args:
54+
seen = set()
55+
56+
def visit(arg):
5457
arg = pathlib.Path(arg)
55-
if arg.suffixes == ['.inc', '.qhelp']:
58+
if arg.resolve() in seen:
59+
return
60+
seen.add(arg.resolve())
61+
if arg.name.endswith(".inc.qhelp"):
5662
for qhelp in find_inc_qhelp_usages(arg):
57-
yield str(qhelp)
63+
yield from visit(qhelp)
5864
else:
5965
yield str(arg)
6066

67+
for arg in args:
68+
yield from visit(arg)
69+
70+
71+
if sys.argv[1:] == ["--list"]:
72+
paths = (os.fsdecode(path) for path in sys.stdin.buffer.read().split(b"\0") if path)
73+
for path in transform_inputs(paths):
74+
sys.stdout.buffer.write(os.fsencode(path) + b"\0")
75+
sys.exit(0)
6176

6277
affected_qhelp_files = list(transform_inputs(sys.argv[1:]))
6378
if not affected_qhelp_files:

0 commit comments

Comments
 (0)