Skip to content

Commit 22d8585

Browse files
committed
Fix recrusive glob bug
1 parent 2583a68 commit 22d8585

File tree

13 files changed

+131
-59
lines changed

13 files changed

+131
-59
lines changed

.github/scripts/extract-notes.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ GITREF=${2}
99
if [[ "${GITREF}" == refs/tags/* ]]; then
1010
TAG="${GITREF#refs/tags/}"
1111
VERSION="${TAG#v}"
12-
MAJMIN=${VERSION%.*}
12+
MACRO_MESO=$(echo "${VERSION}" | cut -d. -f1,2)
1313
else
1414
TAG="unreleased"
1515
VERSION="Unreleased"
16-
MAJMIN="dev"
16+
MACRO_MESO="dev"
1717
fi
1818

1919
# Extract the release notes from the changelog
2020
sed -n "/## \[${VERSION}\]/, /## /{ /##/!p }" docs/changelog.md > notes.md
2121

2222
# Add a link to the release notes
23-
URL="https://${OWNER}.github.io/${SLUG}/${MAJMIN}/changelog/#${TAG}"
23+
URL="https://${OWNER}.github.io/${SLUG}/${MACRO_MESO}/changelog/#${TAG}"
2424
echo "See [docs/changelog/#${TAG}](${URL}) for more details." >> notes.md
2525

2626
# Remove leading and trailing empty lines

.github/workflows/mkdocs.yaml

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,27 @@ name: mkdocs
44
on:
55
push:
66
branches:
7-
# Run on the main branch ...
8-
- main
7+
# Run on the main branch ...
8+
- main
99
tags-ignore:
10-
# ... but not for tags (avoids duplicate work) ...
11-
- '**'
10+
# ... and on releas tags ...
11+
- 'v*'
1212
paths:
13-
# ... and only if relevant files have changed.
14-
- stepup/**
15-
- docs/**
16-
- mkdocs.yaml
17-
- pyproject.toml
18-
- .github/workflows/mkdocs.yaml
13+
# ... and only if relevant files have changed.
14+
- stepup/**
15+
- docs/**
16+
- mkdocs.yaml
17+
- pyproject.toml
18+
- .github/workflows/mkdocs.yaml
1919
pull_request:
2020
# Run tests on pull requests ...
2121
paths:
22-
# ... only if relevant files have changed.
23-
- stepup/**
24-
- docs/**
25-
- mkdocs.yaml
26-
- pyproject.toml
27-
- .github/workflows/mkdocs.yaml
22+
# ... only if relevant files have changed.
23+
- stepup/**
24+
- docs/**
25+
- mkdocs.yaml
26+
- pyproject.toml
27+
- .github/workflows/mkdocs.yaml
2828

2929
permissions:
3030
contents: write
@@ -71,6 +71,12 @@ jobs:
7171
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
7272
- name: Build mkdocs
7373
run: mike deploy dev
74-
- name: Push gh-pages branch to GitHub
74+
- name: Push gh-pages branch with development version of docs
7575
if: github.ref == 'refs/heads/main'
7676
run: git push origin gh-pages
77+
- name: Deploy gh-pages branch with stable version of docs
78+
if: startsWith(github.ref, 'refs/tags/v')
79+
run: |
80+
VERSION="${GITHUB_REF#refs/tags/v}"
81+
MACRO_MESO=$(echo "${VERSION}" | cut -d. -f1,2)
82+
mike deploy $(MACRO_MESO) -u stable -p

.github/workflows/pytest.yaml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,25 @@ name: pytest
22
on:
33
push:
44
branches:
5-
# Run tests for change on the main branch ...
6-
- main
5+
# Run tests for change on the main branch ...
6+
- main
77
tags-ignore:
8-
# ... but not for tags (avoids duplicate work) ...
9-
- '**'
8+
# ... but not for tags (avoids duplicate work) ...
9+
- '**'
1010
paths:
11-
# ... and only if relevant files have changed.
12-
- stepup/**
13-
- tests/**
14-
- pyproject.toml
15-
- .github/workflows/pytest.yaml
11+
# ... and only if relevant files have changed.
12+
- stepup/**
13+
- tests/**
14+
- pyproject.toml
15+
- .github/workflows/pytest.yaml
1616
pull_request:
17-
# Run tests on pull requests ...
17+
# Run tests on pull requests ...
1818
paths:
19-
# ... only if relevant files have changed.
20-
- stepup/**
21-
- tests/**
22-
- pyproject.toml
23-
- .github/workflows/pytest.yaml
19+
# ... only if relevant files have changed.
20+
- stepup/**
21+
- tests/**
22+
- pyproject.toml
23+
- .github/workflows/pytest.yaml
2424

2525
jobs:
2626
tests:

.github/workflows/release.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ jobs:
5151

5252
publish-to-pypi:
5353
name: Publish Python distribution to PyPI
54-
if: startsWith(github.ref, 'refs/tags/') # only publish to PyPI on tag pushes
54+
if: startsWith(github.ref, 'refs/tags/v') # only publish to PyPI on tag pushes
5555
needs:
5656
- build
5757
runs-on: ubuntu-latest

docs/changelog.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,18 @@ and this project adheres to [Effort-based Versioning](https://jacobtomlinson.dev
1010

1111
## [Unreleased][]
1212

13+
(nothing yet)
14+
15+
## [2.0.7][] - 2025-02-06 {: #v2.0.7 }
16+
17+
This release fixes two recursive glob issues.
18+
1319
### Fixed
1420

1521
- Fixed issues with directories matching `glob("...", _defer=True)`,
1622
which are later used as parent directories in various scenarios.
23+
- Fix bug in recursive glob to match `data/inp.txt` with the pattern `data/**/inp.txt`
24+
1725

1826
## [2.0.6][] - 2025-02-05 {: #v2.0.6 }
1927

@@ -350,6 +358,7 @@ This release fixes several bugs.
350358
Initial release
351359

352360
[Unreleased]: https://github.com/reproducible-reporting/stepup-core
361+
[2.0.7]: https://github.com/reproducible-reporting/stepup-core/releases/tag/v2.0.7
353362
[2.0.6]: https://github.com/reproducible-reporting/stepup-core/releases/tag/v2.0.6
354363
[2.0.5]: https://github.com/reproducible-reporting/stepup-core/releases/tag/v2.0.5
355364
[2.0.4]: https://github.com/reproducible-reporting/stepup-core/releases/tag/v2.0.4

stepup/core/nglob.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,9 @@
9292

9393
RE_WILD_PARTS = [
9494
r"^[*][*]$", # recursive ** wildcard, full string
95-
r"^[*][*](?=/)", # recursive ** wildcard, leading
95+
r"^[*][*]/", # recursive ** wildcard, leading
9696
r"(?<=/)[*][*]$", # recursive ** wildcard, trailing
97-
r"(?<=/)[*][*](?=/)", # recursive ** wildcard, middle
97+
r"(?<=/)[*][*]/", # recursive ** wildcard, middle
9898
r"\[.*?]", # anonymous [abc] wildcard
9999
r"[*]", # anonymous * wildcard
100100
r"[?]", # anonymous ? wildcard
@@ -732,6 +732,11 @@ def convert_nglob_to_regex(
732732
regex = r".*"
733733
if last in ["*"]:
734734
replace = True
735+
elif part == "**/":
736+
if last != "**/":
737+
regex = r"(?:.*/|)"
738+
if last in ["*", "**"]:
739+
replace = True
735740
elif part.startswith("[") and part.endswith("]"):
736741
regex = rf"[^{part[2:-1]}]" if part[1] == "!" else rf"[{part[1:-1]}]"
737742
elif part.startswith("${*") and part.endswith("}"):
@@ -819,6 +824,11 @@ def convert_nglob_to_glob(pattern: str, subs: dict[str, str] | None = None) -> s
819824
texts[-1] = "**"
820825
elif texts[-1] != "**":
821826
texts.append("**")
827+
elif part == "**/":
828+
if texts[-1] in ["*"] or texts[-1] == "**":
829+
texts[-1] = "**/"
830+
elif texts[-1] != "**/":
831+
texts.append("**/")
822832
else:
823833
texts.append(part)
824834
return "".join(texts)

tests/examples/deferred_dir_glob/expected_graph.txt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ step:./plan.py
2525
consumes file:./
2626
consumes file:plan.py
2727
creates dg:data/**/
28-
creates file:data/
2928
creates file:data/part1/bar.inp
3029
creates file:data/part1/bar.out
3130
creates file:data/part1/foo.inp
@@ -36,16 +35,12 @@ step:./plan.py
3635
creates file:data/part2/foo.out
3736
creates file:data/part2/sub/other.inp
3837
creates file:data/part2/sub/other.out
39-
40-
file:data/
41-
state = STATIC
42-
created by step:./plan.py
43-
consumes file:./
44-
supplies file:data/part1/
45-
supplies file:data/part2/
38+
creates file:data/top.inp
39+
creates file:data/top.out
4640

4741
dg:data/**/
4842
created by step:./plan.py
43+
creates file:data/
4944
creates file:data/part1/
5045
creates file:data/part2/
5146
creates file:data/part2/sub/
@@ -64,6 +59,15 @@ file:data/part1/
6459
supplies file:data/part1/foo.inp
6560
supplies file:data/part1/foo.out
6661

62+
file:data/
63+
state = STATIC
64+
created by dg:data/**/
65+
consumes file:./
66+
supplies file:data/part1/
67+
supplies file:data/part2/
68+
supplies file:data/top.inp
69+
supplies file:data/top.out
70+
6771
file:data/part1/foo.inp
6872
state = STATIC
6973
created by step:./plan.py
@@ -101,6 +105,11 @@ file:data/part2/sub/
101105
supplies file:data/part2/sub/other.inp
102106
supplies file:data/part2/sub/other.out
103107

108+
file:data/top.inp
109+
state = STATIC
110+
created by step:./plan.py
111+
consumes file:data/
112+
104113
file:data/part1/bar.out
105114
state = STATIC
106115
created by step:./plan.py
@@ -125,3 +134,8 @@ file:data/part2/sub/other.out
125134
state = STATIC
126135
created by step:./plan.py
127136
consumes file:data/part2/sub/
137+
138+
file:data/top.out
139+
state = STATIC
140+
created by step:./plan.py
141+
consumes file:data/

tests/examples/deferred_dir_glob/expected_inp.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"data/part1/foo.inp",
44
"data/part2/bar.inp",
55
"data/part2/foo.inp",
6-
"data/part2/sub/other.inp"
6+
"data/part2/sub/other.inp",
7+
"data/top.inp"
78
]

tests/examples/deferred_dir_glob/expected_out.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@
33
"data/part1/foo.out",
44
"data/part2/bar.out",
55
"data/part2/foo.out",
6-
"data/part2/sub/other.out"
6+
"data/part2/sub/other.out",
7+
"data/top.out"
78
]

tests/examples/deferred_dir_glob/main.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,7 @@ wait
2525

2626
# Check files that are expected to be present and/or missing.
2727
[[ -f plan.py ]] || exit 1
28+
grep 'inp"' current_inp.json
29+
grep 'out"' current_out.json
30+
[[ $(wc -l current_inp.json | cut -d' ' -f1) -eq 8 ]] || exit 1
31+
[[ $(wc -l current_out.json | cut -d' ' -f1) -eq 8 ]] || exit 1

0 commit comments

Comments
 (0)