bmsdna-devtools 1.0.0__tar.gz → 1.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/PKG-INFO +10 -3
  2. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/README.md +9 -2
  3. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/ci_plan.py +9 -5
  4. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/ci_plan_env.py +33 -5
  5. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/worktree.py +21 -5
  6. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/pyproject.toml +1 -1
  7. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_ci_plan_env.py +167 -0
  8. bmsdna_devtools-1.1.1/tests/test_worktree_create.py +110 -0
  9. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/uv.lock +2 -2
  10. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/.github/workflows/auto-release.yml +0 -0
  11. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/.github/workflows/python-publish.yml +0 -0
  12. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/.github/workflows/python-test.yml +0 -0
  13. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/.gitignore +0 -0
  14. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/.python-version +0 -0
  15. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/__init__.py +0 -0
  16. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/_api_dump.py +0 -0
  17. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/ado_auth.py +0 -0
  18. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/ado_issue.py +0 -0
  19. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/agent_mentions.py +0 -0
  20. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/api_usage.py +0 -0
  21. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/app_service_logs.py +0 -0
  22. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/azure_arm.py +0 -0
  23. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/azure_auth.py +0 -0
  24. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/bdt_config.py +0 -0
  25. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/business_user.py +0 -0
  26. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/cli.py +0 -0
  27. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/cli_tools.py +0 -0
  28. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/commit.py +0 -0
  29. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/dead_code.py +0 -0
  30. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/__init__.py +0 -0
  31. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/advisories.py +0 -0
  32. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/cli.py +0 -0
  33. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/cooldown.py +0 -0
  34. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/lockfiles.py +0 -0
  35. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/osv.py +0 -0
  36. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/deps/versions.py +0 -0
  37. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/env_config.py +0 -0
  38. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/env_files.py +0 -0
  39. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/find_injection.py +0 -0
  40. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/find_repo.py +0 -0
  41. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/gh_args.py +0 -0
  42. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/gh_issue.py +0 -0
  43. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/gh_pr.py +0 -0
  44. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/github_api.py +0 -0
  45. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/gitrepo.py +0 -0
  46. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/injection_frontend.py +0 -0
  47. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/injection_python.py +0 -0
  48. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/issue_do.py +0 -0
  49. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/issue_show.py +0 -0
  50. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/issue_watch.py +0 -0
  51. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint.py +0 -0
  52. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint_findings.py +0 -0
  53. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint_models.py +0 -0
  54. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint_sql.py +0 -0
  55. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint_sql_files.py +0 -0
  56. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint_tooling.py +0 -0
  57. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/lint_typescript.py +0 -0
  58. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/logs.py +0 -0
  59. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_build.py +0 -0
  60. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_cancel.py +0 -0
  61. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_choice.py +0 -0
  62. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_create_args.py +0 -0
  63. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_drift.py +0 -0
  64. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_info.py +0 -0
  65. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_issue_link.py +0 -0
  66. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_labels.py +0 -0
  67. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_list.py +0 -0
  68. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_markdown.py +0 -0
  69. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_merge_defaults.py +0 -0
  70. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pr_ref.py +0 -0
  71. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/pull.py +0 -0
  72. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/testdb.py +0 -0
  73. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/translate.py +0 -0
  74. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/__init__.py +0 -0
  75. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/cli.py +0 -0
  76. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/pipeline.py +0 -0
  77. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/pricing.py +0 -0
  78. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/report.py +0 -0
  79. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
  80. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
  81. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
  82. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
  83. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
  84. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
  85. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
  86. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/justfile +0 -0
  87. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/prek.toml +0 -0
  88. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/skills/bmsdna-devtools/SKILL.md +0 -0
  89. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/conftest.py +0 -0
  90. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/fake_github.py +0 -0
  91. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_ado_auth.py +0 -0
  92. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_ado_issue.py +0 -0
  93. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_ado_issue_flow.py +0 -0
  94. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_agent_mentions.py +0 -0
  95. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_api_usage.py +0 -0
  96. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_app_service_logs.py +0 -0
  97. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_azure_arm.py +0 -0
  98. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_bdt_config.py +0 -0
  99. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_business_user.py +0 -0
  100. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_ci_plan.py +0 -0
  101. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_cleanup.py +0 -0
  102. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_commit.py +0 -0
  103. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_deps.py +0 -0
  104. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_issue.py +0 -0
  105. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_pr_create.py +0 -0
  106. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_pr_id.py +0 -0
  107. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_pull.py +0 -0
  108. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_tools.py +0 -0
  109. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_cli_version.py +0 -0
  110. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_commit.py +0 -0
  111. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_deps_advisories.py +0 -0
  112. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_deps_cooldown.py +0 -0
  113. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_deps_lockfiles.py +0 -0
  114. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_deps_osv.py +0 -0
  115. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_deps_versions.py +0 -0
  116. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_env_config.py +0 -0
  117. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_env_files.py +0 -0
  118. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_find_injection.py +0 -0
  119. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_find_repo.py +0 -0
  120. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_gh_issue.py +0 -0
  121. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_gh_pr.py +0 -0
  122. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_github_api.py +0 -0
  123. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_gitrepo.py +0 -0
  124. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_issue_do.py +0 -0
  125. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_issue_for_me.py +0 -0
  126. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_issue_show.py +0 -0
  127. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_issue_watch.py +0 -0
  128. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_lint.py +0 -0
  129. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_lint_models.py +0 -0
  130. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_lint_sql.py +0 -0
  131. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_lint_sql_files.py +0 -0
  132. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_lint_tooling.py +0 -0
  133. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_lint_typescript.py +0 -0
  134. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_logs.py +0 -0
  135. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_build.py +0 -0
  136. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_build_create_options.py +0 -0
  137. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_build_flow.py +0 -0
  138. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_cancel_build.py +0 -0
  139. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_choice.py +0 -0
  140. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_create_args.py +0 -0
  141. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_description_not_truncated.py +0 -0
  142. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_drift.py +0 -0
  143. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_info.py +0 -0
  144. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_issue_link.py +0 -0
  145. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_labels.py +0 -0
  146. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_list.py +0 -0
  147. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_markdown.py +0 -0
  148. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pr_merge_defaults.py +0 -0
  149. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_pull.py +0 -0
  150. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_testdb.py +0 -0
  151. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_translate.py +0 -0
  152. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_usage.py +0 -0
  153. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_wait_timeout.py +0 -0
  154. {bmsdna_devtools-1.0.0 → bmsdna_devtools-1.1.1}/tests/test_worktree_clean.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: bmsdna-devtools
3
- Version: 1.0.0
3
+ Version: 1.1.1
4
4
  Summary: Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects
5
5
  Requires-Python: >=3.14
6
6
  Requires-Dist: azure-identity>=1.19.0
@@ -687,6 +687,8 @@ Creates `.worktrees/<name>` branched from `--base`. It first fetches `origin/<ba
687
687
  a local base that is ahead of or has diverged from the remote is kept as is. Then it initializes submodules
688
688
  (unless `--no-submodules`), and copies an env file into the new worktree as
689
689
  `.env` (auto-detects `.local_env` then `.env` if `--env-file` isn't given).
690
+ Run from a sub-folder of a monorepo, the worktree still covers the whole repo and the env file and `--install` apply to
691
+ that same sub-folder inside it.
690
692
  It also adds `.worktrees/` and `.claude/worktrees/` to the repo root's `.gitignore` if Git
691
693
  doesn't already ignore them, and reminds you to commit the change.
692
694
 
@@ -1003,8 +1005,8 @@ Order of decision, always logged with its reason:
1003
1005
  4. Anything unreadable (label API, change list) runs everything: a missing decision never silently skips tests.
1004
1006
 
1005
1007
  Outputs (Azure Pipelines variables with `isOutput=true`; plain `name=value` lines elsewhere): `runTests`, and per tier
1006
- (`unit`, `e2e`, ...) `<tier>Run`, `<tier>Areas` and `<tier>Paths`, a shell-quoted argument list for the runner (repo-
1007
- relative). A tier you do not configure and split by area (e.g. flat unit tests) is simply gated on `runTests`. For
1008
+ (`unit`, `e2e`, ...) `<tier>Run`, `<tier>Areas` and `<tier>Paths`, a shell-quoted argument list for the runner (relative to the
1009
+ `pyproject.toml` folder). A tier you do not configure and split by area (e.g. flat unit tests) is simply gated on `runTests`. For
1008
1010
  custom sharding or a runner that does not take paths, use `<tier>Areas` (a space-separated list: keep area names free
1009
1011
  of whitespace if you split it): in folder mode the `<tier>Paths` of a full run
1010
1012
  is the bare tier folder, which may also hold things that are not tests (`.venv`, `test-results`); in glob mode it is the
@@ -1034,6 +1036,11 @@ list of test files either way. A moved file counts as changed under both its old
1034
1036
  Dry run locally: `uv run bdt ci plan --pr-source feat/x --pr-target dev --label test-orders` (or without `--label` to
1035
1037
  see what the changed files select).
1036
1038
 
1039
+ A project in a sub-folder of a monorepo: run the plan and the test runner in that folder (where its `pyproject.toml`
1040
+ is). Changed files are matched relative to it, so a file outside is a `../` path: own it with `paths`
1041
+ (`infra = ["../infra/**"]`) or ignore it with `non_code` (`["../other-app/**"]`). Any other outside file (a shared
1042
+ folder) selects everything.
1043
+
1037
1044
  ## `bdt lint`
1038
1045
 
1039
1046
  Static checks (implementing [bmsuisse/skills#52](https://github.com/bmsuisse/skills/issues/52))
@@ -668,6 +668,8 @@ Creates `.worktrees/<name>` branched from `--base`. It first fetches `origin/<ba
668
668
  a local base that is ahead of or has diverged from the remote is kept as is. Then it initializes submodules
669
669
  (unless `--no-submodules`), and copies an env file into the new worktree as
670
670
  `.env` (auto-detects `.local_env` then `.env` if `--env-file` isn't given).
671
+ Run from a sub-folder of a monorepo, the worktree still covers the whole repo and the env file and `--install` apply to
672
+ that same sub-folder inside it.
671
673
  It also adds `.worktrees/` and `.claude/worktrees/` to the repo root's `.gitignore` if Git
672
674
  doesn't already ignore them, and reminds you to commit the change.
673
675
 
@@ -984,8 +986,8 @@ Order of decision, always logged with its reason:
984
986
  4. Anything unreadable (label API, change list) runs everything: a missing decision never silently skips tests.
985
987
 
986
988
  Outputs (Azure Pipelines variables with `isOutput=true`; plain `name=value` lines elsewhere): `runTests`, and per tier
987
- (`unit`, `e2e`, ...) `<tier>Run`, `<tier>Areas` and `<tier>Paths`, a shell-quoted argument list for the runner (repo-
988
- relative). A tier you do not configure and split by area (e.g. flat unit tests) is simply gated on `runTests`. For
989
+ (`unit`, `e2e`, ...) `<tier>Run`, `<tier>Areas` and `<tier>Paths`, a shell-quoted argument list for the runner (relative to the
990
+ `pyproject.toml` folder). A tier you do not configure and split by area (e.g. flat unit tests) is simply gated on `runTests`. For
989
991
  custom sharding or a runner that does not take paths, use `<tier>Areas` (a space-separated list: keep area names free
990
992
  of whitespace if you split it): in folder mode the `<tier>Paths` of a full run
991
993
  is the bare tier folder, which may also hold things that are not tests (`.venv`, `test-results`); in glob mode it is the
@@ -1015,6 +1017,11 @@ list of test files either way. A moved file counts as changed under both its old
1015
1017
  Dry run locally: `uv run bdt ci plan --pr-source feat/x --pr-target dev --label test-orders` (or without `--label` to
1016
1018
  see what the changed files select).
1017
1019
 
1020
+ A project in a sub-folder of a monorepo: run the plan and the test runner in that folder (where its `pyproject.toml`
1021
+ is). Changed files are matched relative to it, so a file outside is a `../` path: own it with `paths`
1022
+ (`infra = ["../infra/**"]`) or ignore it with `non_code` (`["../other-app/**"]`). Any other outside file (a shared
1023
+ folder) selects everything.
1024
+
1018
1025
  ## `bdt lint`
1019
1026
 
1020
1027
  Static checks (implementing [bmsuisse/skills#52](https://github.com/bmsuisse/skills/issues/52))
@@ -16,6 +16,10 @@ Configured under `[tool.bdt.ci.plan]` in pyproject.toml (the table must exist, e
16
16
  [tool.bdt.ci.plan.paths] # non-test files an area owns: changing them infers that area, not everything
17
17
  infra = ["infra/**"] # built-in default when the repo has an infra/ folder (areas may have no tests)
18
18
 
19
+ Monorepo: run the command in the project's folder (the one with the pyproject.toml). Changed files are matched relative
20
+ to that folder, so a file outside it is a `../` path: own it with `paths` (`infra = ["../infra/**"]`) or ignore it with
21
+ `non_code` (`["../other-app/**"]`); any other file outside it (a shared folder) still selects everything.
22
+
19
23
  Labels: `test-<area>`, `test-full` (everything), `test-none` (no tests; lint and build still run). The legacy
20
24
  `e2e-<area>` labels count as `test-<area>`. Order of decision (the reason is always reported):
21
25
 
@@ -100,11 +104,11 @@ class Tier:
100
104
  )
101
105
 
102
106
  def area_of(self, root: Path, path: str, areas: Collection[str]) -> frozenset[str] | None:
103
- """Areas owning a repo-relative file, or None when the file is not an area file of this tier (a helper
104
- folder, a file directly in the tier folder): changing it can affect any test, so the plan runs everything.
105
- In folder mode a file of an area folder counts, helpers like conftest.py included. A test file whose
106
- whole folder was removed still names its (now gone) area. `areas` is `self.areas(root)`, computed once per
107
- plan by the caller."""
107
+ """Areas owning a file (a path relative to the pyproject.toml folder), or None when the file is not an area
108
+ file of this tier (a helper folder, a file directly in the tier folder): changing it can affect any test, so the
109
+ plan runs everything. In folder mode a file of an area folder counts, helpers like conftest.py included. A test
110
+ file whose whole folder was removed still names its (now gone) area. `areas` is `self.areas(root)`, computed once
111
+ per plan by the caller."""
108
112
  pure = PurePosixPath(path)
109
113
  if not pure.is_relative_to(self.dir):
110
114
  return None
@@ -111,15 +111,43 @@ def _git(
111
111
  return done
112
112
 
113
113
 
114
- def changed_files(target: str, *, merge_checkout: bool) -> list[str]:
114
+ def relative_to_root(files: list[str], root: Path) -> list[str]:
115
+ """Git lists paths relative to the repository root, the plan config (`dir`, `paths`, `non_code`) and the paths it
116
+ outputs are relative to the folder of the pyproject.toml. They are the same thing unless the project lives in a
117
+ sub-folder of a monorepo: then a file of the project is listed relative to it (`backend/app.py`) and one outside it
118
+ keeps its place as a `../` path (`../infra/main.bicep`), which the config can match like any other path.
119
+ The project's own prefix comes from git (`--show-prefix`) and is cut from git's own spelling of each path: no
120
+ file-system lookups, so symlinks, case-insensitive file systems and unusual folder names cannot skew it."""
121
+ prefix = _git("-C", str(root), "rev-parse", "--show-prefix").stdout.removesuffix("\n")
122
+ base = prefix.rstrip("/").split("/") if prefix else []
123
+ if not base:
124
+ return files
125
+ result = []
126
+ for name in files:
127
+ parts = name.split("/")
128
+ common = 0
129
+ while common < len(base) and common < len(parts) - 1 and parts[common] == base[common]:
130
+ common += 1
131
+ result.append("../" * (len(base) - common) + "/".join(parts[common:]))
132
+ return result
133
+
134
+
135
+ def changed_files(target: str, *, merge_checkout: bool, root: Path | None = None) -> list[str]:
115
136
  """Files the PR changes: in CI HEAD is the synthetic PR merge commit, compared with its first parent (the target);
116
137
  for a local dry run the branch is compared with `origin/<target>` (it may contain ordinary merges).
138
+ With `root` (the project folder, when it is not the repository root) the paths are relative to it, see
139
+ `relative_to_root`.
117
140
  `--no-renames` lists a moved file under its old path too: rename detection would hide the old path, so code moved
118
141
  into a `non_code` folder (or a test moved between areas) would look like nothing happened to the old place.
119
- `-z` keeps non-ASCII and other unusual names unquoted (git's default quoting would defeat every glob)."""
142
+ `-c diff.relative=false` keeps the paths relative to the repository root whatever the user configured (the plan
143
+ normalises them itself, see `relative_to_root`; unlike `--no-relative` it works on any git version). `-z` keeps non-ASCII and other unusual names unquoted (git's default
144
+ quoting would defeat every glob)."""
120
145
  diff = ("HEAD^1", "HEAD") if merge_checkout else (f"origin/{target}...HEAD",)
121
- out = _git("diff", "--name-only", "--no-renames", "-z", *diff).stdout
122
- return [path for path in out.split("\0") if path] # -z: git would quote names like test_\303\274ber.py
146
+ # `-C root`: the same repository the prefix is taken from, whatever the process cwd is.
147
+ where = ["-C", str(root)] if root is not None else []
148
+ out = _git(*where, "-c", "diff.relative=false", "diff", "--name-only", "--no-renames", "-z", *diff).stdout
149
+ files = [path for path in out.split("\0") if path] # -z: git would quote names like test_\303\274ber.py
150
+ return files if root is None else relative_to_root(files, root)
123
151
 
124
152
 
125
153
  def verify_fix_base(env: Mapping[str, str]) -> None:
@@ -214,7 +242,7 @@ def run(
214
242
  ctx,
215
243
  config,
216
244
  labels=label_provider,
217
- changed_files=lambda: changed_files(ctx.target, merge_checkout=not dry_run),
245
+ changed_files=lambda: changed_files(ctx.target, merge_checkout=not dry_run, root=config.root),
218
246
  verify_fix_base=lambda: verify_fix_base(env),
219
247
  )
220
248
  for warning in plan.warnings:
@@ -137,12 +137,28 @@ def create(
137
137
  if path.exists():
138
138
  sys.exit(f"error: {path} already exists")
139
139
 
140
+ # Run from a sub-folder of a monorepo, the worktree still holds the whole repository: the env file and the install
141
+ # command belong in the same sub-folder of it (`<worktree>/app`), the project, not in the worktree's top level.
142
+ # Asked before the worktree exists, so a failure leaves nothing behind.
143
+ found = _run_capture(["git", "rev-parse", "--show-prefix"], cwd=root)
144
+ if found.returncode != 0:
145
+ sys.exit(f"error: {root} is not inside a git work tree: {found.stderr.strip()}")
146
+ prefix = found.stdout.removesuffix("\n")
147
+
140
148
  start, remote_start = _start_point(root, base)
141
149
  # --no-track: the new branch must not push to / compare against origin/<base>
142
150
  _run(["git", "worktree", "add", *(["--no-track"] if remote_start else []), str(path), "-b", name, start], cwd=root)
143
151
  _ensure_worktree_gitignore(root)
144
152
 
145
- if submodules and (root / ".gitmodules").exists():
153
+ project = path / prefix if prefix else path
154
+ if not project.is_dir():
155
+ print(
156
+ f"warning: {base} has no {prefix}; the env file and the install command use the worktree root",
157
+ file=sys.stderr,
158
+ )
159
+ project = path
160
+
161
+ if submodules and (path / ".gitmodules").exists():
146
162
  _run(["git", "submodule", "update", "--init"], cwd=path)
147
163
 
148
164
  if env_file is None:
@@ -152,12 +168,12 @@ def create(
152
168
  break
153
169
 
154
170
  if env_file and (root / env_file).exists():
155
- shutil.copy(root / env_file, path / ".env")
171
+ shutil.copy(root / env_file, project / ".env")
156
172
 
157
173
  if install_cmd:
158
- _run(install_cmd, cwd=path)
174
+ _run(install_cmd, cwd=project)
159
175
 
160
- print(f"worktree ready at {path}")
176
+ print(f"worktree ready at {project}")
161
177
  # A worktree based on the remote's actual DEFAULT branch makes `bdt pull`'s
162
178
  # separate default-branch step redundant. base in ("main", "master") is
163
179
  # only a *guess* at that (wrong on a repo whose configured default is e.g.
@@ -180,7 +196,7 @@ def create(
180
196
  )
181
197
  else:
182
198
  print("Hint: run `bdt pull` in it to pull the latest main/master and default branch.")
183
- return path
199
+ return project
184
200
 
185
201
 
186
202
  # --- Discovery: repos and their worktrees -------------------------------
@@ -10,7 +10,7 @@ packages = ["bmsdna"]
10
10
 
11
11
  [project]
12
12
  name = "bmsdna-devtools"
13
- version = "1.0.0"
13
+ version = "1.1.1"
14
14
  description = "Shared Azure DevOps / GitHub / git / Azure Monitor developer tooling for BMS projects"
15
15
  readme = "README.md"
16
16
  requires-python = ">=3.14" # pgdevkit>=0.7.1 requires 3.14; was >=3.11 before adding it as a dependency
@@ -369,3 +369,170 @@ def test_changed_files_keeps_non_ascii_names_unquoted(clone, monkeypatch) -> Non
369
369
  git(clone, "add", "-A")
370
370
  git(clone, "commit", "-q", "-m", "umlaut")
371
371
  assert ci_plan_env.changed_files("main", merge_checkout=False) == ["tests/test_über.py"]
372
+
373
+
374
+ # --- a project in a sub-folder of a monorepo ----------------------------------------------------------------------
375
+
376
+
377
+ def test_changed_files_are_relative_to_the_project_folder(clone, monkeypatch) -> None:
378
+ """The project lives in app/: its files are listed relative to it, all others keep their place as `../` paths."""
379
+ git(clone, "checkout", "-q", "-b", "feat")
380
+ for name in ("app/code.py", "infra/main.bicep", "other/x.txt"):
381
+ (clone / name).parent.mkdir(exist_ok=True)
382
+ (clone / name).write_text(name)
383
+ git(clone, "add", "-A")
384
+ git(clone, "commit", "-q", "-m", "mono")
385
+ monkeypatch.chdir(clone / "app")
386
+
387
+ inside = ci_plan_env.changed_files("main", merge_checkout=False, root=clone / "app")
388
+ assert sorted(inside) == ["../infra/main.bicep", "../other/x.txt", "code.py"]
389
+ at_top = ci_plan_env.changed_files("main", merge_checkout=False, root=clone)
390
+ assert sorted(at_top) == ["app/code.py", "infra/main.bicep", "other/x.txt"] # root == repository root: unchanged
391
+ assert sorted(ci_plan_env.changed_files("main", merge_checkout=False)) == sorted(at_top) # no root: unchanged
392
+
393
+
394
+ @pytest.fixture
395
+ def monorepo(clone, monkeypatch):
396
+ """dev holds a project in app/ (config: shared infra/ owned by `infra`, other-app/ ignored) next to infra/,
397
+ other-app/ and a shared database/; HEAD is a feature branch cut from it, the cwd is the project folder."""
398
+ git(clone, "checkout", "-q", "dev")
399
+ files = {
400
+ "app/pyproject.toml": (
401
+ '[tool.bdt.ci.plan]\nnon_code = ["../other-app/**"]\n\n[tool.bdt.ci.plan.paths]\ninfra = ["../infra/**"]\n'
402
+ ),
403
+ "app/tests/unit/orders/test_a.py": "",
404
+ "infra/main.bicep": "a",
405
+ "other-app/x.py": "a",
406
+ "database/a.sql": "a",
407
+ }
408
+ for name, content in files.items():
409
+ (clone / name).parent.mkdir(parents=True, exist_ok=True)
410
+ (clone / name).write_text(content)
411
+ git(clone, "add", "-A")
412
+ git(clone, "commit", "-q", "-m", "monorepo")
413
+ git(clone, "push", "-q", "origin", "dev")
414
+ git(clone, "checkout", "-q", "-b", "feat")
415
+ for key in (*PR_ENV, "BUILD_REASON"):
416
+ monkeypatch.delenv(key, raising=False)
417
+ monkeypatch.chdir(clone / "app")
418
+ return clone
419
+
420
+
421
+ def _dry_run_changing(monorepo, name: str) -> str:
422
+ (monorepo / name).write_text("changed")
423
+ git(monorepo, "add", "-A")
424
+ git(monorepo, "commit", "-q", "-m", "change")
425
+ result = CliRunner().invoke(app, ["ci", "plan", "--pr-source", "feat", "--pr-target", "dev"])
426
+ assert result.exit_code == 0, result.output
427
+ return result.output
428
+
429
+
430
+ def test_monorepo_shared_infra_selects_the_infra_area_only(monorepo) -> None:
431
+ output = _dry_run_changing(monorepo, "infra/main.bicep")
432
+ assert "test plan: areas (changed area tests: infra)" in output
433
+ assert "runTests=true" in output and "unitRun=false" in output
434
+
435
+
436
+ def test_monorepo_other_app_changes_run_no_tests(monorepo) -> None:
437
+ output = _dry_run_changing(monorepo, "other-app/x.py")
438
+ assert "test plan: none" in output and "runTests=false" in output
439
+
440
+
441
+ def test_monorepo_shared_folder_changes_run_everything(monorepo) -> None:
442
+ output = _dry_run_changing(monorepo, "database/a.sql")
443
+ assert "test plan: full (../database/a.sql is not owned by an area" in output
444
+ assert "unitPaths=tests/unit" in output
445
+
446
+
447
+ def test_monorepo_own_test_file_selects_its_area(monorepo) -> None:
448
+ output = _dry_run_changing(monorepo, "app/tests/unit/orders/test_a.py")
449
+ assert "test plan: areas (changed area tests: orders)" in output
450
+ assert "unitPaths=tests/unit/orders" in output
451
+
452
+
453
+ def test_changed_files_ignore_a_configured_diff_relative(clone, monkeypatch) -> None:
454
+ """`git config diff.relative true` would make git itself drop what is outside the folder and re-root the rest."""
455
+ git(clone, "config", "diff.relative", "true")
456
+ git(clone, "checkout", "-q", "-b", "feat")
457
+ for name in ("app/code.py", "infra/main.bicep"):
458
+ (clone / name).parent.mkdir(exist_ok=True)
459
+ (clone / name).write_text(name)
460
+ git(clone, "add", "-A")
461
+ git(clone, "commit", "-q", "-m", "mono")
462
+ monkeypatch.chdir(clone / "app")
463
+ assert sorted(ci_plan_env.changed_files("main", merge_checkout=False, root=clone / "app")) == [
464
+ "../infra/main.bicep",
465
+ "code.py",
466
+ ]
467
+
468
+
469
+ def test_changed_files_of_a_project_nested_two_levels_deep(clone, monkeypatch) -> None:
470
+ git(clone, "checkout", "-q", "-b", "feat")
471
+ for name in ("apps/app/code.py", "apps/other/x.py", "apps/app/sub/y.py", "infra/main.bicep"):
472
+ (clone / name).parent.mkdir(parents=True, exist_ok=True)
473
+ (clone / name).write_text(name)
474
+ git(clone, "add", "-A")
475
+ git(clone, "commit", "-q", "-m", "mono")
476
+ monkeypatch.chdir(clone) # the process cwd does not matter, the project root does
477
+ files = ci_plan_env.changed_files("main", merge_checkout=False, root=clone / "apps" / "app")
478
+ assert sorted(files) == ["../../infra/main.bicep", "../other/x.py", "code.py", "sub/y.py"]
479
+
480
+
481
+ def test_changed_files_for_a_repository_folder_ending_in_a_space(tmp_path, monkeypatch) -> None:
482
+ """Paths come from git's own spelling, not from comparing file-system paths: odd folder names change nothing."""
483
+ work = tmp_path / "repo "
484
+ work.mkdir()
485
+ git(work, "init", "-q", "-b", "main")
486
+ commit(work, "m1")
487
+ git(work, "update-ref", "refs/remotes/origin/main", "HEAD")
488
+ git(work, "checkout", "-q", "-b", "feat")
489
+ (work / "app").mkdir()
490
+ (work / "app/code.py").write_text("x")
491
+ git(work, "add", "-A")
492
+ git(work, "commit", "-q", "-m", "app")
493
+ monkeypatch.chdir(work / "app")
494
+ assert ci_plan_env.changed_files("main", merge_checkout=False, root=work / "app") == ["code.py"]
495
+ assert ci_plan_env.changed_files("main", merge_checkout=False, root=work) == ["app/code.py"]
496
+
497
+
498
+ def test_changed_files_of_the_merge_commit_in_ci_for_a_sub_folder_project(clone, monkeypatch) -> None:
499
+ """The CI path (HEAD is the PR merge commit, compared with its first parent), with the project in a sub-folder."""
500
+ git(clone, "checkout", "-q", "-b", "feat")
501
+ for name in ("app/code.py", "infra/main.bicep"):
502
+ (clone / name).parent.mkdir(exist_ok=True)
503
+ (clone / name).write_text(name)
504
+ git(clone, "add", "-A")
505
+ git(clone, "commit", "-q", "-m", "mono")
506
+ git(clone, "checkout", "-q", "main")
507
+ git(clone, "merge", "-q", "--no-ff", "-m", "merge", "feat")
508
+ monkeypatch.chdir(clone)
509
+ files = ci_plan_env.changed_files("main", merge_checkout=True, root=clone / "app")
510
+ assert sorted(files) == ["../infra/main.bicep", "code.py"]
511
+
512
+
513
+ def test_a_sibling_folder_sharing_the_project_folder_name_as_a_prefix_stays_outside(clone, monkeypatch) -> None:
514
+ git(clone, "checkout", "-q", "-b", "feat")
515
+ for name in ("app/code.py", "app2/code.py"):
516
+ (clone / name).parent.mkdir(exist_ok=True)
517
+ (clone / name).write_text(name)
518
+ git(clone, "add", "-A")
519
+ git(clone, "commit", "-q", "-m", "mono")
520
+ monkeypatch.chdir(clone / "app")
521
+ assert sorted(ci_plan_env.changed_files("main", merge_checkout=False, root=clone / "app")) == [
522
+ "../app2/code.py",
523
+ "code.py",
524
+ ]
525
+
526
+
527
+ def test_the_diff_runs_in_the_project_repository_not_the_process_cwd(clone, tmp_path, monkeypatch) -> None:
528
+ """cwd is another repository: the prefix and the diff must both come from the project's."""
529
+ git(clone, "checkout", "-q", "-b", "feat")
530
+ (clone / "app").mkdir()
531
+ (clone / "app/code.py").write_text("x")
532
+ git(clone, "add", "-A")
533
+ git(clone, "commit", "-q", "-m", "app")
534
+ elsewhere = tmp_path / "elsewhere"
535
+ elsewhere.mkdir()
536
+ git(elsewhere, "init", "-q", "-b", "main")
537
+ monkeypatch.chdir(elsewhere)
538
+ assert ci_plan_env.changed_files("main", merge_checkout=False, root=clone / "app") == ["code.py"]
@@ -0,0 +1,110 @@
1
+ """`worktree.create`: where the env file and the install command go, at the repo root and in a monorepo sub-folder."""
2
+
3
+ import subprocess
4
+ from pathlib import Path
5
+
6
+ import pytest
7
+
8
+ from bmsdna.devtools import worktree
9
+
10
+
11
+ def git(cwd: Path, *args: str) -> None:
12
+ subprocess.run(["git", *args], cwd=cwd, check=True, capture_output=True, text=True)
13
+
14
+
15
+ @pytest.fixture
16
+ def repo(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> Path:
17
+ for key, value in {"NAME": "t", "EMAIL": "t@t"}.items():
18
+ monkeypatch.setenv(f"GIT_AUTHOR_{key}", value)
19
+ monkeypatch.setenv(f"GIT_COMMITTER_{key}", value)
20
+ work = tmp_path / "repo"
21
+ (work / "app").mkdir(parents=True)
22
+ git(work, "init", "-q", "-b", "main")
23
+ (work / "app" / "code.py").write_text("x")
24
+ (work / ".gitignore").write_text(".worktrees/\n")
25
+ git(work, "add", "-A")
26
+ git(work, "commit", "-q", "-m", "init")
27
+ (work / ".local_env").write_text("ROOT=1")
28
+ (work / "app" / ".local_env").write_text("APP=1")
29
+ return work
30
+
31
+
32
+ INSTALL = ["sh", "-c", "pwd -P > where.txt"]
33
+
34
+
35
+ def test_at_the_repo_root_env_and_install_use_the_worktree_root(repo: Path, monkeypatch: pytest.MonkeyPatch) -> None:
36
+ monkeypatch.chdir(repo)
37
+ worktree.create("feat", base="main", install_cmd=INSTALL)
38
+ wt = repo / ".worktrees" / "feat"
39
+ assert (wt / ".env").read_text() == "ROOT=1"
40
+ assert (wt / "where.txt").read_text().strip() == str(wt.resolve())
41
+
42
+
43
+ def test_in_a_sub_folder_env_and_install_use_the_same_sub_folder_of_the_worktree(
44
+ repo: Path, monkeypatch: pytest.MonkeyPatch
45
+ ) -> None:
46
+ monkeypatch.chdir(repo / "app")
47
+ worktree.create("feat", base="main", install_cmd=INSTALL)
48
+ wt = repo / "app" / ".worktrees" / "feat"
49
+ assert (wt / "app" / "code.py").is_file() # the worktree holds the whole repository
50
+ assert (wt / "app" / ".env").read_text() == "APP=1"
51
+ assert (wt / "app" / "where.txt").read_text().strip() == str((wt / "app").resolve())
52
+ assert not (wt / ".env").exists() and not (wt / "where.txt").exists()
53
+
54
+
55
+ def test_the_ready_message_names_the_project_folder(
56
+ repo: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
57
+ ) -> None:
58
+ monkeypatch.chdir(repo / "app")
59
+ worktree.create("feat", base="main")
60
+ assert f"worktree ready at {repo / 'app' / '.worktrees' / 'feat' / 'app'}" in capsys.readouterr().out
61
+
62
+
63
+ def test_a_base_without_the_project_folder_falls_back_to_the_worktree_root(
64
+ repo: Path, monkeypatch: pytest.MonkeyPatch, capsys: pytest.CaptureFixture[str]
65
+ ) -> None:
66
+ empty = subprocess.run(
67
+ ["git", "mktree"], cwd=repo, input="", capture_output=True, text=True, check=True
68
+ ).stdout.strip()
69
+ commit = subprocess.run(
70
+ ["git", "commit-tree", empty, "-m", "no app here"], cwd=repo, capture_output=True, text=True, check=True
71
+ ).stdout.strip()
72
+ git(repo, "branch", "bare", commit)
73
+ monkeypatch.chdir(repo / "app")
74
+ worktree.create("feat", base="bare", install_cmd=INSTALL)
75
+ wt = repo / "app" / ".worktrees" / "feat"
76
+ assert (wt / "where.txt").is_file() and (wt / ".env").read_text() == "APP=1"
77
+ assert "has no app/" in capsys.readouterr().err
78
+
79
+
80
+ def test_an_explicit_env_file_is_taken_from_the_sub_folder(repo: Path, monkeypatch: pytest.MonkeyPatch) -> None:
81
+ (repo / "app" / "custom_env").write_text("CUSTOM=1")
82
+ monkeypatch.chdir(repo / "app")
83
+ worktree.create("feat", base="main", env_file="custom_env")
84
+ assert (repo / "app" / ".worktrees" / "feat" / "app" / ".env").read_text() == "CUSTOM=1"
85
+
86
+
87
+ def test_submodules_are_initialised_when_gitmodules_sits_at_the_repo_top(
88
+ repo: Path, monkeypatch: pytest.MonkeyPatch
89
+ ) -> None:
90
+ (repo / ".gitmodules").write_text("")
91
+ git(repo, "add", ".gitmodules")
92
+ git(repo, "commit", "-q", "-m", "gitmodules")
93
+ calls: list[list[str]] = []
94
+ real = worktree._run
95
+ monkeypatch.setattr(worktree, "_run", lambda cmd, cwd: (calls.append(cmd), real(cmd, cwd))[1])
96
+ monkeypatch.chdir(repo / "app")
97
+ worktree.create("feat", base="main")
98
+ assert ["git", "submodule", "update", "--init"] in calls
99
+
100
+
101
+ def test_outside_a_git_work_tree_nothing_is_created(tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
102
+ monkeypatch.chdir(tmp_path)
103
+ with pytest.raises(SystemExit, match="not inside a git work tree"):
104
+ worktree.create("feat", base="main")
105
+ assert not (tmp_path / ".worktrees").exists()
106
+
107
+
108
+ def test_create_returns_the_folder_it_announces(repo: Path, monkeypatch: pytest.MonkeyPatch) -> None:
109
+ monkeypatch.chdir(repo / "app")
110
+ assert worktree.create("feat", base="main") == repo / "app" / ".worktrees" / "feat" / "app"
@@ -1,5 +1,5 @@
1
1
  version = 1
2
- revision = 3
2
+ revision = 5
3
3
  requires-python = ">=3.14"
4
4
 
5
5
  [[package]]
@@ -51,7 +51,7 @@ wheels = [
51
51
 
52
52
  [[package]]
53
53
  name = "bmsdna-devtools"
54
- version = "1.0.0"
54
+ version = "1.1.1"
55
55
  source = { editable = "." }
56
56
  dependencies = [
57
57
  { name = "azure-identity" },