33Used by `poe sync-spec-assets` for local development and CI testing. The hatch
44build hook (hatch_build.py) handles inclusion in the wheel and sdist.
55
6- The assets are owned by open-feature/spec, not by this repository. Copying them
7- in at build time -- rather than committing copies -- means the spec revision this
8- package was built against is recorded by the submodule pin and nowhere else, so
9- the two cannot drift apart unnoticed. An *adopter* installing the wheel still
10- needs no submodule: the copies are inside the distribution.
6+ The assets are owned by open-feature/spec. Copying them in at build time rather
7+ than committing copies means the submodule pin is the only record of the spec
8+ revision this package was built against, so the two cannot drift apart
9+ unnoticed.
1110
1211Copying is the second half of the job. The first is making sure the submodule
1312working tree is at the revision the pin names, because **a rebase moves the
3534
3635For the one workflow that legitimately wants it: drafting a change to the
3736canonical assets in a local spec checkout before there is a revision to pin. It
38- warns on every sync, and it names the revision actually in use, because a suite
37+ warns on every sync and names the revision actually in use, because a suite
3938running against assets nobody can identify must not be quiet about it.
4039"""
4140
4746
4847# (source directory or file, destination) relative to SPEC_ASSETS / DEST_BASE.
4948#
50- # "gherkin" copies to a directory of the same name on purpose, and the pair is not
51- # redundant: a canonical feature is identified by its path relative to the asset
52- # directory, so the destination name *is* the reported uri prefix. Renaming it
53- # locally -- it used to land in "features" -- silently renamed the uri, which is
54- # how this suite reported features/errors.feature for the file Go reports as
55- # gherkin/errors.feature. Keep the two equal.
49+ # "gherkin" copies to a directory of the same name on purpose: a canonical
50+ # feature is identified by its path relative to the asset directory, so the
51+ # destination name *is* the reported uri prefix. Renaming it locally silently
52+ # renames the uri every language's report is keyed by. Keep the two equal.
5653TREES = [("gherkin" , "gherkin" ), ("flags" , "flag_data" )]
5754FILES = [("openapi/control-api.yaml" , "control-api.yaml" )]
5855
6158
6259A seam, so the decision `checkout_pinned_spec` makes can be tested without a
6360fixture repository on disk. Failure is ``None`` rather than an exception because
64- every caller here treats "git could not answer" as a state to report rather than
65- a crash: building from an unpacked sdist has no repository at all.
61+ every caller treats "git could not answer" as a state to report: building from
62+ an unpacked sdist has no repository at all.
6663"""
6764
6865
@@ -83,24 +80,21 @@ def _run_git(args: Sequence[str], cwd: Path) -> str | None:
8380def superproject_git_dir (git : GitRunner = _run_git ) -> str | None :
8481 """The superproject's git directory, asked of the submodule instead.
8582
86- For the one environment where git cannot find the superproject on its own:
87- a linked worktree records its git directory as an **absolute** path in the
88- worktree's ``.git`` file, and a process in a different filesystem namespace
89- -- WSL reading a worktree that Windows git created, which is where the
90- stale-asset run below actually happened -- cannot follow it. A submodule's
91- ``.git`` file is *relative*, so git inside the submodule answers there and
92- git in the superproject does not, and the pin is the half that only the
93- superproject has.
94-
95- The derivation is git's own layout rather than a guess about paths: a
96- submodule's git directory is ``<superproject git dir>/modules/<path in the
97- superproject>``, so the ancestor named ``modules`` has the answer as its
98- parent. Read from the bottom, so a submodule inside a submodule resolves to
99- its immediate superproject rather than the outermost one.
100-
101- ``None`` when there is no submodule repository to ask -- an unpacked sdist
102- -- or when the layout is not that one, in which case the caller is no worse
103- off than before.
83+ **For the environment where git cannot find the superproject on its own:** a
84+ linked worktree records its git directory as an **absolute** path in the
85+ worktree's ``.git`` file, which a process in a different filesystem namespace
86+ -- WSL reading a worktree Windows git created -- cannot follow. A submodule's
87+ ``.git`` file is *relative*, so git inside the submodule answers where git in
88+ the superproject does not, and the pin is the half only the superproject has.
89+
90+ The derivation is git's own layout: a submodule's git directory is
91+ ``<superproject git dir>/modules/<path in the superproject>``, so the
92+ ancestor named ``modules`` has the answer as its parent. Read from the
93+ bottom, so a submodule inside a submodule resolves to its immediate
94+ superproject.
95+
96+ ``None`` when there is no submodule repository to ask -- an unpacked sdist --
97+ or when the layout is not that one.
10498 """
10599 common = git (["rev-parse" , "--git-common-dir" ], SPEC_ROOT )
106100 if not common :
@@ -131,11 +125,10 @@ def pinned_revision(git: GitRunner = _run_git) -> str | None:
131125 will record and so what a run is about to claim it tested against. ``None``
132126 when there is no repository to ask, which is ordinary: an sdist has none.
133127
134- Asked twice before giving up, and the second way is not a fallback so much
135- as the same question routed around an unreachable path: see
136- :func:`superproject_git_dir`. Only an answer of *nothing* is retried -- an
137- entry that is present and is not a gitlink is a definite answer, and asking
138- again would not change it.
128+ Asked twice before giving up, the second way being the same question routed
129+ around an unreachable path -- see :func:`superproject_git_dir`. Only an answer
130+ of *nothing* is retried; an entry that is present and is not a gitlink is a
131+ definite answer.
139132 """
140133 entry = git (["ls-files" , "-s" , "--" , SPEC_DIRNAME ], ROOT )
141134 if not entry :
@@ -179,33 +172,24 @@ def _pin_entry_through_the_submodule(git: GitRunner) -> str | None:
179172def checkout_pinned_spec (git : GitRunner = _run_git ) -> str | None :
180173 """Bring the submodule working tree to the revision the pin names.
181174
182- **This is the reason this function exists: a rebase moves the gitlink and
183- not the submodule's working tree.** So a checkout can have a pin saying one
184- revision and assets on disk from another, and nothing about the build says
185- so. That is not hypothetical -- it happened here, the copied Gherkin was one
186- pin behind the capability the suite was declaring, and a self-test of the
187- enum against the assets is what caught it. That guard fires for one symptom.
188- A pin that changes only the *content* of a scenario would pass every guard
189- in this package and still run the wrong suite, which is what happened in
190- another language: a whole adoption suite ran against stale assets and
191- reported byte-identical numbers to the previous pass, and nothing failed and
192- nothing warned.
193-
194- So the checkout is part of the copy rather than something the operator is
195- expected to remember, and the copy is a dependency of the test task. The
196- suite cannot run against assets it did not just fetch.
175+ **This is why this function exists: a rebase moves the gitlink and not the
176+ submodule's working tree.** So a checkout can have a pin naming one revision
177+ and assets on disk from another, and nothing about the build says so. A pin
178+ that changes only the *content* of a scenario passes every other guard in
179+ this package and still runs the wrong suite. So the checkout is part of the
180+ copy rather than something the operator is expected to remember, and the copy
181+ is a dependency of the test task.
197182
198183 Returns the pinned revision, or ``None`` when there is no pin to read.
199184
200- **When the pin cannot be read this warns rather than failing.** Building
201- from an unpacked sdist is the ordinary case -- no repository, no pin, and
202- the assets are already in the tree. The other case is a git checkout whose
203- superproject this process cannot reach, which happens for a linked worktree
204- whose ``.git`` file names a path in another filesystem namespace: git inside
205- the submodule answers, git in the superproject does not. Warning rather than
206- failing keeps that environment usable; the warning is what says the
207- guarantee is not in force, and the remedy is to run the sync from a shell
208- that can see the superproject.
185+ **When the pin cannot be read this warns rather than failing.** An unpacked
186+ sdist has no pin and no working tree that could have drifted, so there is
187+ nothing to check rather than a check that cannot run -- failing there would
188+ accuse a downstream packager of a defect they cannot fix. The other case is a
189+ checkout whose superproject this process cannot reach (see
190+ :func:`superproject_git_dir`); the warning is what says the guarantee is not
191+ in force, and the remedy is to sync from a shell that can see the
192+ superproject.
209193 """
210194 if os .environ .get (UNPINNED_ENV ):
211195 head = git (["rev-parse" , "HEAD" ], SPEC_ROOT )
0 commit comments