Commit d4b9beb
Fix layout-fragile git-root assertion in source code metadata test (#25855)
## Summary & Motivation
The `test_link_code_references_to_git_if_cloud_cloud_context[github]`,
`[gitlab]`, and
`test_link_code_references_to_git_if_cloud_override_cloud_context` cases
were failing in buildkite. The expected git URLs hardcoded
`dagster-oss/python_modules/dagster-cloud`, but
`link_code_references_to_git_if_cloud` derives the repository path as
the file path relative to the nearest `.git` ancestor (via
`_locate_git_root` + `AnchorBasedFilePathMapping`). That is
checkout-layout-dependent: it resolves to
`dagster-oss/python_modules/dagster-cloud/...` in an internal dev
checkout (so the test passed locally) but to
`python_modules/dagster-cloud/...` in buildkite, where the package sits
at the OSS-style layout under its own git root. The code is correct —
the test was layout-fragile.
The fix asserts only the layout-independent parts of the URL: the
branch-base prefix (`startswith`) and the stable
`dagster-cloud/.../file#Ln` tail (`endswith`). The repo prefix in
between (`dagster-oss/python_modules/` vs `python_modules/`) is exactly
the env-dependent segment that shouldn't be pinned — pinning it was the
original bug. It also drops the dead, wrong-depth `GIT_ROOT_PATH`
constant. Since this file is copybara-synced, the fix propagates to
`dagster-io/dagster`, whose identical copy has the same fragility.
## Test Plan
`tox -e py312-default -- -k link_code_references` — all 6 cases pass.
ruff and ty clean. The assertions no longer depend on where `.git` sits
relative to the package, so they hold in every layout (internal dev,
buildkite, OSS).
## Changelog
NOCHANGELOG
Internal-RevId: 75edf6efe4e5f540e1b9fe26a28ac3641b39cbc11 parent 93a9d89 commit d4b9beb
1 file changed
Lines changed: 10 additions & 9 deletions
File tree
- python_modules/dagster-cloud/dagster_cloud_tests/metadata_tests
Lines changed: 10 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | 23 | | |
25 | 24 | | |
26 | 25 | | |
| |||
152 | 151 | | |
153 | 152 | | |
154 | 153 | | |
155 | | - | |
156 | | - | |
157 | | - | |
158 | | - | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
159 | 158 | | |
160 | 159 | | |
161 | 160 | | |
| |||
225 | 224 | | |
226 | 225 | | |
227 | 226 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
232 | 233 | | |
233 | 234 | | |
234 | 235 | | |
| |||
0 commit comments