bmsdna-devtools 0.54.0__tar.gz → 0.56.0__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.
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/PKG-INFO +47 -2
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/README.md +46 -1
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/cli.py +43 -1
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/find_repo.py +242 -10
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/gh_pr.py +1 -1
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_build.py +35 -1
- bmsdna_devtools-0.56.0/bmsdna/devtools/pr_drift.py +153 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_info.py +43 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/pyproject.toml +1 -1
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/skills/bmsdna-devtools/SKILL.md +19 -1
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_find_repo.py +320 -1
- bmsdna_devtools-0.56.0/tests/test_pr_drift.py +353 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_info.py +4 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/uv.lock +2 -2
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/.github/workflows/auto-release.yml +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/.github/workflows/python-publish.yml +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/.github/workflows/python-test.yml +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/.gitignore +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/.python-version +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/__init__.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/_api_dump.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/ado_auth.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/ado_issue.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/agent_mentions.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/api_usage.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/app_service_logs.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/azure_arm.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/azure_auth.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/bdt_config.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/business_user.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/ci_plan.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/ci_plan_env.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/cli_tools.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/commit.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/dead_code.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/deps/__init__.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/deps/advisories.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/deps/cli.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/deps/lockfiles.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/deps/osv.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/deps/versions.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/env_config.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/env_files.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/find_injection.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/gh_args.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/gh_issue.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/github_api.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/gitrepo.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/injection_frontend.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/injection_python.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/issue_do.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/issue_show.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/issue_watch.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint_findings.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint_models.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint_sql.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint_sql_files.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint_tooling.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/lint_typescript.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/logs.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_cancel.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_choice.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_create_args.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_issue_link.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_labels.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_markdown.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_merge_defaults.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pr_ref.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/pull.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/testdb.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/translate.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/__init__.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/cli.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/pipeline.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/pricing.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/report.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/00_schema.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/01_ingest_claude.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/01_ingest_codex.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/02_messages.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/03_markers.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/04_facts.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/usage/sql/05_views.sql +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/bmsdna/devtools/worktree.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/justfile +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/conftest.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/fake_github.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_ado_auth.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_ado_issue.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_ado_issue_flow.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_agent_mentions.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_api_usage.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_app_service_logs.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_azure_arm.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_bdt_config.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_business_user.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_ci_plan.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_ci_plan_env.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_cleanup.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_commit.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_deps.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_issue.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_pr_create.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_pr_id.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_pull.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_tools.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_cli_version.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_commit.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_deps_advisories.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_deps_lockfiles.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_deps_osv.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_deps_versions.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_env_config.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_env_files.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_find_injection.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_gh_issue.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_gh_pr.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_github_api.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_gitrepo.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_issue_do.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_issue_for_me.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_issue_show.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_issue_watch.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_lint.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_lint_models.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_lint_sql.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_lint_sql_files.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_lint_tooling.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_lint_typescript.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_logs.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_build.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_build_create_options.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_build_flow.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_cancel_build.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_choice.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_create_args.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_description_not_truncated.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_issue_link.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_labels.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_markdown.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pr_merge_defaults.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_pull.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_testdb.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_translate.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_usage.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_wait_timeout.py +0 -0
- {bmsdna_devtools-0.54.0 → bmsdna_devtools-0.56.0}/tests/test_worktree_clean.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: bmsdna-devtools
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.56.0
|
|
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
|
|
@@ -82,6 +82,18 @@ for builds/checks that will never run — e.g. on Azure DevOps:
|
|
|
82
82
|
on GitHub: `PR #42 ('feat: widgets') has merge conflicts with 'main' (mergeable=CONFLICTING)`.
|
|
83
83
|
Exit code 1 either way.
|
|
84
84
|
|
|
85
|
+
On Azure DevOps that status is only as current as the PR's last push: it is never recomputed when the **target
|
|
86
|
+
branch** moves on, so a PR can say `succeeded` while the target has since changed the same lines (and its builds ran
|
|
87
|
+
on the old merge). `pr status` therefore also compares the target's tip with the commit the merge status was
|
|
88
|
+
computed against; if they differ it fetches both by commit id and merges them locally with `git merge-tree` (no
|
|
89
|
+
working-tree change, no branch or tag created; the answer is cached in `.git/bdt-merge-check.json` per commit). A
|
|
90
|
+
conflict is reported like the server's, exit 1: `PR #42 ('feat: widgets') has merge conflicts with 'dev' (mergeStatus=succeeded
|
|
91
|
+
is stale: 'dev' has moved on by 3 commits since it was computed). Conflicting: a.txt. Merge or rebase 'dev' into the branch and push.`
|
|
92
|
+
A target that moved without conflicts is a one-line `Note:`. This runs at the start and on every poll of `--wait` (one
|
|
93
|
+
cheap request each, the merge itself only when the target moved again), so a conflict that appears while CI runs
|
|
94
|
+
stops the wait. It needs a checkout of the repo (without one the note says the target moved but not whether it
|
|
95
|
+
conflicts) and is skipped quietly if Azure DevOps or git can't answer. GitHub recomputes `mergeable` itself.
|
|
96
|
+
|
|
85
97
|
With `--wait`, a build/check that's paused on a manual approval (an Azure
|
|
86
98
|
Pipelines stage's Checkpoint.Approval, or a GitHub Actions deployment
|
|
87
99
|
protection rule) ends the wait instead of polling forever — it prints which
|
|
@@ -137,7 +149,7 @@ from the latest build of each pipeline (any failed result fails it; unfinished b
|
|
|
137
149
|
`--all` lists every open PR from the current branch (e.g. one into `dev` and one into `main`, which plain
|
|
138
150
|
`bdt pr info` refuses to pick between): with `--json` an array of the same objects, `[]` (exit 0) when there is
|
|
139
151
|
none; `--target-branch` narrows it, `--pr-id` can't be combined with it. Only open PRs are listed, and a PR with
|
|
140
|
-
merge conflicts is listed like any other (plain `pr info` on Azure DevOps errors on
|
|
152
|
+
merge conflicts is listed like any other, with `merge: conflicts` (plain `pr info` on Azure DevOps errors on one the server already reports).
|
|
141
153
|
|
|
142
154
|
`--pr-id` takes several PRs, also of other repos: repeat it and/or comma-separate (`--pr-id 12,34 --pr-id owner/repo#5`).
|
|
143
155
|
Each entry is a bare number (a PR of the current repo), `owner/repo#N` (GitHub), `project/repo#N` or
|
|
@@ -152,6 +164,12 @@ every org, and a PR with merge conflicts is an error entry there.
|
|
|
152
164
|
|
|
153
165
|
Every JSON object has a `repo` (`owner/repo` on GitHub, `org/project/repo` on Azure DevOps).
|
|
154
166
|
|
|
167
|
+
It also says whether the PR still merges into its `target` branch: `merge` is `clean`, `conflicts` (with the
|
|
168
|
+
`conflicts` paths when known), `behind` (the target moved on, but it still merges; `target_behind` = by how many
|
|
169
|
+
commits), `unknown` (it moved on and couldn't be checked, see `bdt pr status`) or `none` (not an open PR). On
|
|
170
|
+
Azure DevOps this is the drift check of `bdt pr status`, which is why `merge` can say `conflicts` while the server
|
|
171
|
+
still reports `succeeded`; on GitHub it is `mergeable`.
|
|
172
|
+
|
|
155
173
|
Azure DevOps limits: the PR is found by the current branch (into `--target-branch` if given, else any target),
|
|
156
174
|
a PR with merge conflicts is reported as an error (exit 1) like `pr status` does, and the closed
|
|
157
175
|
work items are only those whose URL is in the PR description -- not ones linked via
|
|
@@ -688,6 +706,33 @@ Set the org env vars in your shell profile to make `bdt find-repo <name>` work a
|
|
|
688
706
|
the `cross-repo-discovery` skill's `ALL_REPOS.md` sync. Needs ADO auth / a GitHub token only when
|
|
689
707
|
those orgs are searched.
|
|
690
708
|
|
|
709
|
+
## `bdt list-repo`
|
|
710
|
+
|
|
711
|
+
```bash
|
|
712
|
+
bdt list-repo [--root ~/projects] [--org MYORG] [--github-org MYORG] [--local] [--fast] [--json] [--pat PAT]
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
The browse counterpart to `bdt find-repo`: lists **every** repo of the Azure DevOps org and/or GitHub org
|
|
716
|
+
(same flags and env vars as `find-repo`), sorted by project and name, one line each:
|
|
717
|
+
|
|
718
|
+
```text
|
|
719
|
+
bmsuisse/bicep-cost 2026-11-06 fbf7e85f Adrian Ehrsam CLI for estimating Costs for Azure Infra, based on Bicep
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
The columns are the newest commit's date, short id and author, then a one-line description. With no org
|
|
723
|
+
configured, or with `--local`, it lists the clones under the work dir instead (the path takes the place of
|
|
724
|
+
`project/repo`; the commit is the newest one on any branch of the clone).
|
|
725
|
+
|
|
726
|
+
- **Description:** GitHub has a repo description and it is used. Azure DevOps repos and local clones have none, so the
|
|
727
|
+
first sentence of the README stands in (empty if there is no README, or only badges, headings and template text).
|
|
728
|
+
- **Commit:** the newest commit of the default branch (GitHub / Azure DevOps).
|
|
729
|
+
- **Cost:** GitHub needs one extra request per repo for the commit, Azure DevOps two (commit and README); all run concurrently
|
|
730
|
+
(about 15 s for ~400 Azure DevOps repos). `--fast` skips them: GitHub then shows only its last push date,
|
|
731
|
+
Azure DevOps repos no commit and no description. Repos without commits, or whose commits can't be read, have empty fields.
|
|
732
|
+
- **`--json`:** prints an array of objects for scripts instead of the aligned text, with full (untruncated) values:
|
|
733
|
+
`project`, `name`, `source` (`ado`/`github`), `url`, `last_commit_id`, `last_commit_date` (ISO 8601),
|
|
734
|
+
`last_commit_author`, `description` -- local clones have `name` and `location` instead of `project`/`source`/`url`.
|
|
735
|
+
|
|
691
736
|
## `bdt cleanup worktrees` / `bdt cleanup orphaned-dbs` / `bdt cleanup db` / `bdt cleanup worktree`
|
|
692
737
|
|
|
693
738
|
```bash
|
|
@@ -63,6 +63,18 @@ for builds/checks that will never run — e.g. on Azure DevOps:
|
|
|
63
63
|
on GitHub: `PR #42 ('feat: widgets') has merge conflicts with 'main' (mergeable=CONFLICTING)`.
|
|
64
64
|
Exit code 1 either way.
|
|
65
65
|
|
|
66
|
+
On Azure DevOps that status is only as current as the PR's last push: it is never recomputed when the **target
|
|
67
|
+
branch** moves on, so a PR can say `succeeded` while the target has since changed the same lines (and its builds ran
|
|
68
|
+
on the old merge). `pr status` therefore also compares the target's tip with the commit the merge status was
|
|
69
|
+
computed against; if they differ it fetches both by commit id and merges them locally with `git merge-tree` (no
|
|
70
|
+
working-tree change, no branch or tag created; the answer is cached in `.git/bdt-merge-check.json` per commit). A
|
|
71
|
+
conflict is reported like the server's, exit 1: `PR #42 ('feat: widgets') has merge conflicts with 'dev' (mergeStatus=succeeded
|
|
72
|
+
is stale: 'dev' has moved on by 3 commits since it was computed). Conflicting: a.txt. Merge or rebase 'dev' into the branch and push.`
|
|
73
|
+
A target that moved without conflicts is a one-line `Note:`. This runs at the start and on every poll of `--wait` (one
|
|
74
|
+
cheap request each, the merge itself only when the target moved again), so a conflict that appears while CI runs
|
|
75
|
+
stops the wait. It needs a checkout of the repo (without one the note says the target moved but not whether it
|
|
76
|
+
conflicts) and is skipped quietly if Azure DevOps or git can't answer. GitHub recomputes `mergeable` itself.
|
|
77
|
+
|
|
66
78
|
With `--wait`, a build/check that's paused on a manual approval (an Azure
|
|
67
79
|
Pipelines stage's Checkpoint.Approval, or a GitHub Actions deployment
|
|
68
80
|
protection rule) ends the wait instead of polling forever — it prints which
|
|
@@ -118,7 +130,7 @@ from the latest build of each pipeline (any failed result fails it; unfinished b
|
|
|
118
130
|
`--all` lists every open PR from the current branch (e.g. one into `dev` and one into `main`, which plain
|
|
119
131
|
`bdt pr info` refuses to pick between): with `--json` an array of the same objects, `[]` (exit 0) when there is
|
|
120
132
|
none; `--target-branch` narrows it, `--pr-id` can't be combined with it. Only open PRs are listed, and a PR with
|
|
121
|
-
merge conflicts is listed like any other (plain `pr info` on Azure DevOps errors on
|
|
133
|
+
merge conflicts is listed like any other, with `merge: conflicts` (plain `pr info` on Azure DevOps errors on one the server already reports).
|
|
122
134
|
|
|
123
135
|
`--pr-id` takes several PRs, also of other repos: repeat it and/or comma-separate (`--pr-id 12,34 --pr-id owner/repo#5`).
|
|
124
136
|
Each entry is a bare number (a PR of the current repo), `owner/repo#N` (GitHub), `project/repo#N` or
|
|
@@ -133,6 +145,12 @@ every org, and a PR with merge conflicts is an error entry there.
|
|
|
133
145
|
|
|
134
146
|
Every JSON object has a `repo` (`owner/repo` on GitHub, `org/project/repo` on Azure DevOps).
|
|
135
147
|
|
|
148
|
+
It also says whether the PR still merges into its `target` branch: `merge` is `clean`, `conflicts` (with the
|
|
149
|
+
`conflicts` paths when known), `behind` (the target moved on, but it still merges; `target_behind` = by how many
|
|
150
|
+
commits), `unknown` (it moved on and couldn't be checked, see `bdt pr status`) or `none` (not an open PR). On
|
|
151
|
+
Azure DevOps this is the drift check of `bdt pr status`, which is why `merge` can say `conflicts` while the server
|
|
152
|
+
still reports `succeeded`; on GitHub it is `mergeable`.
|
|
153
|
+
|
|
136
154
|
Azure DevOps limits: the PR is found by the current branch (into `--target-branch` if given, else any target),
|
|
137
155
|
a PR with merge conflicts is reported as an error (exit 1) like `pr status` does, and the closed
|
|
138
156
|
work items are only those whose URL is in the PR description -- not ones linked via
|
|
@@ -669,6 +687,33 @@ Set the org env vars in your shell profile to make `bdt find-repo <name>` work a
|
|
|
669
687
|
the `cross-repo-discovery` skill's `ALL_REPOS.md` sync. Needs ADO auth / a GitHub token only when
|
|
670
688
|
those orgs are searched.
|
|
671
689
|
|
|
690
|
+
## `bdt list-repo`
|
|
691
|
+
|
|
692
|
+
```bash
|
|
693
|
+
bdt list-repo [--root ~/projects] [--org MYORG] [--github-org MYORG] [--local] [--fast] [--json] [--pat PAT]
|
|
694
|
+
```
|
|
695
|
+
|
|
696
|
+
The browse counterpart to `bdt find-repo`: lists **every** repo of the Azure DevOps org and/or GitHub org
|
|
697
|
+
(same flags and env vars as `find-repo`), sorted by project and name, one line each:
|
|
698
|
+
|
|
699
|
+
```text
|
|
700
|
+
bmsuisse/bicep-cost 2026-11-06 fbf7e85f Adrian Ehrsam CLI for estimating Costs for Azure Infra, based on Bicep
|
|
701
|
+
```
|
|
702
|
+
|
|
703
|
+
The columns are the newest commit's date, short id and author, then a one-line description. With no org
|
|
704
|
+
configured, or with `--local`, it lists the clones under the work dir instead (the path takes the place of
|
|
705
|
+
`project/repo`; the commit is the newest one on any branch of the clone).
|
|
706
|
+
|
|
707
|
+
- **Description:** GitHub has a repo description and it is used. Azure DevOps repos and local clones have none, so the
|
|
708
|
+
first sentence of the README stands in (empty if there is no README, or only badges, headings and template text).
|
|
709
|
+
- **Commit:** the newest commit of the default branch (GitHub / Azure DevOps).
|
|
710
|
+
- **Cost:** GitHub needs one extra request per repo for the commit, Azure DevOps two (commit and README); all run concurrently
|
|
711
|
+
(about 15 s for ~400 Azure DevOps repos). `--fast` skips them: GitHub then shows only its last push date,
|
|
712
|
+
Azure DevOps repos no commit and no description. Repos without commits, or whose commits can't be read, have empty fields.
|
|
713
|
+
- **`--json`:** prints an array of objects for scripts instead of the aligned text, with full (untruncated) values:
|
|
714
|
+
`project`, `name`, `source` (`ado`/`github`), `url`, `last_commit_id`, `last_commit_date` (ISO 8601),
|
|
715
|
+
`last_commit_author`, `description` -- local clones have `name` and `location` instead of `project`/`source`/`url`.
|
|
716
|
+
|
|
672
717
|
## `bdt cleanup worktrees` / `bdt cleanup orphaned-dbs` / `bdt cleanup db` / `bdt cleanup worktree`
|
|
673
718
|
|
|
674
719
|
```bash
|
|
@@ -595,9 +595,14 @@ def pr_status(
|
|
|
595
595
|
|
|
596
596
|
|
|
597
597
|
def _info_text(info: pr_info_mod.PrInfo, with_repo: bool = False) -> str:
|
|
598
|
-
|
|
598
|
+
merge = [f"merge: {info.merge}"] if info.merge not in (pr_info_mod.MERGE_CLEAN, pr_info_mod.MERGE_NONE) else []
|
|
599
|
+
flags = ", ".join([info.state, *(["draft"] if info.draft else []), f"build: {info.build}", *merge])
|
|
599
600
|
name = f"PR {info.repo}#{info.number}" if with_repo and info.repo else f"PR #{info.number}"
|
|
600
601
|
lines = [f"{name}: {info.title} ({flags})", info.url]
|
|
602
|
+
if info.merge == pr_info_mod.MERGE_CONFLICTS:
|
|
603
|
+
lines.append(f"Conflicts with '{info.target}'" + (f": {', '.join(info.conflicts)}" if info.conflicts else ""))
|
|
604
|
+
elif info.merge in (pr_info_mod.MERGE_BEHIND, pr_info_mod.MERGE_UNKNOWN) and info.target_behind:
|
|
605
|
+
lines.append(f"'{info.target}' moved on by {info.target_behind} commit{'s' * (info.target_behind != 1)} since the PR's last merge check")
|
|
601
606
|
if info.abandon_reason:
|
|
602
607
|
lines.append(pr_cancel.abandoned_notice(pr_cancel.Reason(info.abandon_reason, info.abandon_session)))
|
|
603
608
|
if info.build == pr_info_mod.BUILD_CANCELLED:
|
|
@@ -1992,6 +1997,43 @@ def find_repo_cmd(
|
|
|
1992
1997
|
find_repo_mod.run(name, root=root, org=org, github_org=github_org, yes=yes, pat=pat)
|
|
1993
1998
|
|
|
1994
1999
|
|
|
2000
|
+
@app.command("list-repo")
|
|
2001
|
+
def list_repo_cmd(
|
|
2002
|
+
root: Path | None = typer.Option(
|
|
2003
|
+
None,
|
|
2004
|
+
"--root",
|
|
2005
|
+
help="Local work dir to list when no org is set or with --local (default: $AZDO_WORK_DIR/$BMS_WORK_DIR, falling back to ~/projects, or C:/Projects on Windows)",
|
|
2006
|
+
),
|
|
2007
|
+
org: str | None = typer.Option(None, "--org", envvar=["AZDO_ORG", "BMS_ORG"], help="Azure DevOps org to list"),
|
|
2008
|
+
github_org: str | None = typer.Option(
|
|
2009
|
+
None, "--github-org", envvar=["GITHUB_ORG", "BMS_GITHUB_ORG"], help="GitHub org to list"
|
|
2010
|
+
),
|
|
2011
|
+
local: bool = typer.Option(False, "--local", help="List the local clones under --root even if an org is configured"),
|
|
2012
|
+
fast: bool = typer.Option(
|
|
2013
|
+
False,
|
|
2014
|
+
"--fast",
|
|
2015
|
+
help="Skip the extra requests per repo (newest commit; for Azure DevOps also the README). GitHub then shows only "
|
|
2016
|
+
"its last push date, Azure DevOps repos no commit and no description",
|
|
2017
|
+
),
|
|
2018
|
+
as_json: bool = typer.Option(False, "--json", help="Print a JSON array instead of aligned text"),
|
|
2019
|
+
pat: str | None = typer.Option(
|
|
2020
|
+
None,
|
|
2021
|
+
"--pat",
|
|
2022
|
+
envvar=["AZURE_DEVOPS_EXT_PAT", "AZURE_DEVOPS_PAT"],
|
|
2023
|
+
help="Azure DevOps PAT (else uses DefaultAzureCredential, e.g. your `az login`)",
|
|
2024
|
+
),
|
|
2025
|
+
) -> None:
|
|
2026
|
+
"""List all repos with last commit (date, id, author) and a one-line description -- the browse counterpart to `find-repo`.
|
|
2027
|
+
|
|
2028
|
+
Lists every repo of the Azure DevOps org and/or GitHub org (same --org/--github-org and env vars
|
|
2029
|
+
as `find-repo`); with no org configured, or with --local, the clones under the work dir.
|
|
2030
|
+
GitHub supplies its own description. Azure DevOps and local repos have none, so the first sentence of
|
|
2031
|
+
the README stands in. The commit is the newest one of the default branch on GitHub / Azure DevOps and of
|
|
2032
|
+
any branch in a local clone. --json gives the same data as an array of objects, with full ids and dates.
|
|
2033
|
+
"""
|
|
2034
|
+
find_repo_mod.run_list(root=root, org=org, github_org=github_org, local=local, fast=fast, as_json=as_json, pat=pat)
|
|
2035
|
+
|
|
2036
|
+
|
|
1995
2037
|
@cleanup_app.command("worktrees")
|
|
1996
2038
|
def cleanup_worktrees(
|
|
1997
2039
|
root: Path = typer.Argument(Path("."), help="Root folder to scan for git repositories (recursively)"),
|
|
@@ -3,6 +3,9 @@ an Azure DevOps org and/or a GitHub org, without needing the full
|
|
|
3
3
|
`ALL_REPOS.md` org sync that the `cross-repo-discovery` skill
|
|
4
4
|
(bmsuisse/skills) used to require.
|
|
5
5
|
|
|
6
|
+
`bdt list-repo` is the browse counterpart: every repo of the same orgs (or the local clones) with its
|
|
7
|
+
newest commit and a one-line description.
|
|
8
|
+
|
|
6
9
|
Env vars mirror that skill's so switching over needs no reconfiguration:
|
|
7
10
|
- `AZDO_WORK_DIR` / `BMS_WORK_DIR`: local clone root to search (and to clone
|
|
8
11
|
a remote match into). Falls back to `C:/Projects` on Windows, `~/projects`
|
|
@@ -18,12 +21,14 @@ Env vars mirror that skill's so switching over needs no reconfiguration:
|
|
|
18
21
|
from __future__ import annotations
|
|
19
22
|
|
|
20
23
|
import base64
|
|
24
|
+
import json
|
|
21
25
|
import os
|
|
26
|
+
import re
|
|
22
27
|
import subprocess
|
|
23
28
|
import sys
|
|
24
29
|
from collections.abc import Callable
|
|
25
30
|
from concurrent.futures import ThreadPoolExecutor
|
|
26
|
-
from dataclasses import dataclass
|
|
31
|
+
from dataclasses import dataclass, replace
|
|
27
32
|
from pathlib import Path
|
|
28
33
|
from typing import TypeVar
|
|
29
34
|
from urllib.parse import quote
|
|
@@ -64,12 +69,23 @@ def find_local(name: str, root: Path) -> list[Path]:
|
|
|
64
69
|
return sorted(_prefer_exact(find_repos(root), name, key=lambda r: r.name))
|
|
65
70
|
|
|
66
71
|
|
|
72
|
+
@dataclass(frozen=True)
|
|
73
|
+
class CommitInfo:
|
|
74
|
+
"""Newest commit of a repo; every field is "" where the source doesn't tell."""
|
|
75
|
+
|
|
76
|
+
id: str = ""
|
|
77
|
+
date: str = "" # ISO 8601
|
|
78
|
+
author: str = ""
|
|
79
|
+
|
|
80
|
+
|
|
67
81
|
@dataclass(frozen=True)
|
|
68
82
|
class RemoteRepo:
|
|
69
83
|
project: str
|
|
70
84
|
name: str
|
|
71
85
|
remote_url: str
|
|
72
86
|
source: str = "ado"
|
|
87
|
+
description: str = ""
|
|
88
|
+
last_commit: CommitInfo = CommitInfo()
|
|
73
89
|
|
|
74
90
|
|
|
75
91
|
ADO_API_VERSION = "7.1"
|
|
@@ -120,8 +136,8 @@ def _ado_projects(org: str, headers: dict[str, str]) -> list[dict]:
|
|
|
120
136
|
skip += len(page)
|
|
121
137
|
|
|
122
138
|
|
|
123
|
-
def
|
|
124
|
-
"""
|
|
139
|
+
def _ado_all_repos(org: str, headers: dict[str, str]) -> list[RemoteRepo]:
|
|
140
|
+
"""Every repo of every project in `org`.
|
|
125
141
|
|
|
126
142
|
Azure DevOps has no "search repos by name across the whole org" API, so
|
|
127
143
|
(as the old skill's script did) this lists every project and then every
|
|
@@ -129,7 +145,6 @@ def find_remote(org: str, name: str, pat: str | None = None) -> list[RemoteRepo]
|
|
|
129
145
|
run concurrently (each is just an HTTP request waiting on network I/O)
|
|
130
146
|
since with dozens of projects a serial fan-out is the dominant cost.
|
|
131
147
|
"""
|
|
132
|
-
headers = auth_header(pat) # resolved once, shared by the worker threads
|
|
133
148
|
projects = _ado_projects(org, headers)
|
|
134
149
|
|
|
135
150
|
def repos_for(project: dict) -> list[RemoteRepo]:
|
|
@@ -146,12 +161,17 @@ def find_remote(org: str, name: str, pat: str | None = None) -> list[RemoteRepo]
|
|
|
146
161
|
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
147
162
|
for repos in pool.map(repos_for, projects):
|
|
148
163
|
all_repos.extend(repos)
|
|
164
|
+
return all_repos
|
|
165
|
+
|
|
149
166
|
|
|
150
|
-
|
|
167
|
+
def find_remote(org: str, name: str, pat: str | None = None) -> list[RemoteRepo]:
|
|
168
|
+
"""Search every project in `org` for a repo matching `name` -- see `_prefer_exact`."""
|
|
169
|
+
headers = auth_header(pat) # resolved once, shared by the worker threads
|
|
170
|
+
return _prefer_exact(_ado_all_repos(org, headers), name, key=lambda r: r.name)
|
|
151
171
|
|
|
152
172
|
|
|
153
|
-
def
|
|
154
|
-
"""
|
|
173
|
+
def _github_all_repos(client: GitHubClient, org: str, limit: int | None = 1000) -> list[RemoteRepo]:
|
|
174
|
+
"""Every repo of `org`'s GitHub account.
|
|
155
175
|
|
|
156
176
|
Unlike Azure DevOps, GitHub has a single flat list of repos per org/user
|
|
157
177
|
(no per-project split), so one paginated listing covers the whole org. `org` may
|
|
@@ -165,9 +185,221 @@ def find_github(client: GitHubClient, org: str, name: str) -> list[RemoteRepo]:
|
|
|
165
185
|
path, params = "user/repos", {"affiliation": "owner"}
|
|
166
186
|
else:
|
|
167
187
|
path = f"users/{org_path}/repos"
|
|
168
|
-
items = client.paginate(path, params, limit=
|
|
169
|
-
|
|
170
|
-
|
|
188
|
+
items = client.paginate(path, params, limit=limit)
|
|
189
|
+
return [
|
|
190
|
+
RemoteRepo(
|
|
191
|
+
org, r["name"], r["html_url"], source="github", description=r.get("description") or "", last_commit=CommitInfo(date=r.get("pushed_at") or "")
|
|
192
|
+
)
|
|
193
|
+
for r in items
|
|
194
|
+
]
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
def find_github(client: GitHubClient, org: str, name: str) -> list[RemoteRepo]:
|
|
198
|
+
"""Search `org`'s GitHub repos for a match -- see `_prefer_exact`."""
|
|
199
|
+
return _prefer_exact(_github_all_repos(client, org), name, key=lambda r: r.name)
|
|
200
|
+
|
|
201
|
+
|
|
202
|
+
DESCRIPTION_MAX_LEN = 120
|
|
203
|
+
README_NAMES = ("README.md", "readme.md", "README.markdown", "README")
|
|
204
|
+
# Lines that open a README but say nothing about the repo: badges, images, HTML, tables, fences, rules.
|
|
205
|
+
_README_NOISE_PREFIXES = ("![", "[![", "<", "|", "`", "---", "===", "***")
|
|
206
|
+
# Numbered-list lines: the default Azure DevOps README template ("1. Installation process 2. ...") is all of them.
|
|
207
|
+
_NUMBERED_LINE = re.compile(r"\d+[.)]\s")
|
|
208
|
+
_SENTENCE_END = re.compile(r"(?<!\d)[.!?](\s|$)")
|
|
209
|
+
|
|
210
|
+
|
|
211
|
+
def _is_readme_noise(line: str) -> bool:
|
|
212
|
+
return (
|
|
213
|
+
line.startswith(_README_NOISE_PREFIXES)
|
|
214
|
+
or line.upper().startswith("TODO")
|
|
215
|
+
or bool(_NUMBERED_LINE.match(line))
|
|
216
|
+
or not any(c.isalpha() for c in line)
|
|
217
|
+
)
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
def readme_summary(text: str) -> str:
|
|
221
|
+
"""One-line description from a README: the first sentence of its first prose paragraph, else its
|
|
222
|
+
first heading's text.
|
|
223
|
+
|
|
224
|
+
Azure DevOps repos have no description field, so the README is the closest thing to one.
|
|
225
|
+
"""
|
|
226
|
+
heading = ""
|
|
227
|
+
paragraph: list[str] = []
|
|
228
|
+
for raw in [*text.splitlines(), ""]: # trailing "" closes a paragraph that runs to the end
|
|
229
|
+
line = raw.strip()
|
|
230
|
+
if line.startswith("#"):
|
|
231
|
+
heading = heading or line.lstrip("#").strip()
|
|
232
|
+
line = ""
|
|
233
|
+
elif _is_readme_noise(line):
|
|
234
|
+
line = ""
|
|
235
|
+
if line:
|
|
236
|
+
paragraph.append(line.lstrip(">-* ").strip())
|
|
237
|
+
elif paragraph:
|
|
238
|
+
break
|
|
239
|
+
summary = " ".join(paragraph)
|
|
240
|
+
match = _SENTENCE_END.search(summary)
|
|
241
|
+
summary = summary[: match.start() + 1] if match else summary or heading
|
|
242
|
+
return summary if len(summary) <= DESCRIPTION_MAX_LEN else summary[: DESCRIPTION_MAX_LEN - 1].rstrip() + "…"
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
def _ado_details(org: str, repo: RemoteRepo, headers: dict[str, str]) -> RemoteRepo:
|
|
246
|
+
"""`repo` plus README-derived description and default-branch last commit date (Azure DevOps has neither on the repo)."""
|
|
247
|
+
base = f"https://dev.azure.com/{quote(org)}/{quote(repo.project)}/_apis/git/repositories/{quote(repo.name)}"
|
|
248
|
+
# No README / empty repo / no access to the content: just a blank field, not a failed listing.
|
|
249
|
+
# JSON is requested explicitly: without it the items API answers with the raw file instead of `content`.
|
|
250
|
+
description = ""
|
|
251
|
+
for name in README_NAMES:
|
|
252
|
+
ok, readme = _ado_get(
|
|
253
|
+
f"{base}/items", {**headers, "Accept": "application/json"}, {"path": f"/{name}", "includeContent": "true"}
|
|
254
|
+
)
|
|
255
|
+
if ok and isinstance(readme, dict):
|
|
256
|
+
description = readme_summary(readme.get("content") or "")
|
|
257
|
+
break
|
|
258
|
+
ok, commits = _ado_get(f"{base}/commits", headers, {"searchCriteria.$top": 1})
|
|
259
|
+
last_commit = CommitInfo()
|
|
260
|
+
if ok and isinstance(commits, dict) and commits.get("value"):
|
|
261
|
+
c = commits["value"][0]
|
|
262
|
+
last_commit = CommitInfo(c.get("commitId", ""), c.get("committer", {}).get("date", ""), c.get("author", {}).get("name", ""))
|
|
263
|
+
return replace(repo, description=description, last_commit=last_commit)
|
|
264
|
+
|
|
265
|
+
|
|
266
|
+
def _github_last_commit(client: GitHubClient, repo: RemoteRepo) -> RemoteRepo:
|
|
267
|
+
"""`repo` with its default branch's newest commit (the repo listing only has the last push time)."""
|
|
268
|
+
# Any HTTP error is non-fatal for the listing (like a failing ADO project): keep the push time from the listing.
|
|
269
|
+
# 404/409 (no access / empty repo) are expected; anything else (rate limit, 5xx) is worth a warning.
|
|
270
|
+
r = client.request(
|
|
271
|
+
"GET",
|
|
272
|
+
f"repos/{quote(repo.project, safe='')}/{quote(repo.name, safe='')}/commits",
|
|
273
|
+
ok=tuple(range(400, 600)),
|
|
274
|
+
params={"per_page": 1},
|
|
275
|
+
)
|
|
276
|
+
if r.status_code not in (200, 404, 409):
|
|
277
|
+
print(f"warning: couldn't read the newest commit of '{repo.project}/{repo.name}': HTTP {r.status_code}", file=sys.stderr)
|
|
278
|
+
commits = r.json() if r.status_code == 200 else []
|
|
279
|
+
if not commits:
|
|
280
|
+
return repo
|
|
281
|
+
c = commits[0]
|
|
282
|
+
git = c.get("commit", {})
|
|
283
|
+
return replace(repo, last_commit=CommitInfo(c.get("sha", ""), git.get("committer", {}).get("date", ""), git.get("author", {}).get("name", "")))
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
def list_remote(
|
|
287
|
+
*, org: str | None, github_org: str | None, pat: str | None = None, fast: bool = False
|
|
288
|
+
) -> list[RemoteRepo]:
|
|
289
|
+
"""Every repo of `org` (Azure DevOps) and/or `github_org` (GitHub), sorted by project and name.
|
|
290
|
+
|
|
291
|
+
GitHub repos carry their description and last push time already. Unless `fast`, each repo also costs
|
|
292
|
+
one request for its newest commit (id, author, exact date) -- GitHub -- or two (that plus the README
|
|
293
|
+
for a description, which Azure DevOps lacks) -- Azure DevOps. They run concurrently like the project fan-out.
|
|
294
|
+
"""
|
|
295
|
+
repos: list[RemoteRepo] = []
|
|
296
|
+
headers = auth_header(pat) if org else {}
|
|
297
|
+
gh = require_gh() if github_org else None
|
|
298
|
+
with ThreadPoolExecutor(max_workers=2) as pool:
|
|
299
|
+
searches = []
|
|
300
|
+
if org:
|
|
301
|
+
searches.append(pool.submit(_ado_all_repos, org, headers))
|
|
302
|
+
if github_org and gh:
|
|
303
|
+
searches.append(pool.submit(_github_all_repos, gh, github_org, None)) # no cap: it lists *all* repos
|
|
304
|
+
for search in searches:
|
|
305
|
+
repos += search.result()
|
|
306
|
+
|
|
307
|
+
if not fast:
|
|
308
|
+
def details(r: RemoteRepo) -> RemoteRepo:
|
|
309
|
+
if r.source == "github":
|
|
310
|
+
assert gh
|
|
311
|
+
return _github_last_commit(gh, r)
|
|
312
|
+
assert org
|
|
313
|
+
return _ado_details(org, r, headers)
|
|
314
|
+
|
|
315
|
+
with ThreadPoolExecutor(max_workers=8) as pool:
|
|
316
|
+
repos = list(pool.map(details, repos))
|
|
317
|
+
return sorted(repos, key=lambda r: (r.project.lower(), r.name.lower()))
|
|
318
|
+
|
|
319
|
+
|
|
320
|
+
def _local_last_commit(path: Path) -> CommitInfo:
|
|
321
|
+
"""Newest commit across all of a clone's branches (empty for a clone without commits)."""
|
|
322
|
+
try:
|
|
323
|
+
r = subprocess.run(
|
|
324
|
+
["git", "log", "-1", "--all", "--format=%H%x00%cI%x00%an"], cwd=path, capture_output=True, text=True, check=False
|
|
325
|
+
)
|
|
326
|
+
except FileNotFoundError:
|
|
327
|
+
sys.exit("'git' is required for this command but wasn't found on PATH.")
|
|
328
|
+
parts = r.stdout.strip().split("\x00")
|
|
329
|
+
return CommitInfo(*parts) if len(parts) == 3 else CommitInfo()
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def list_local(root: Path) -> list[tuple[Path, str, CommitInfo]]:
|
|
333
|
+
"""Every clone under `root` as (path, README one-liner, newest commit)."""
|
|
334
|
+
result = []
|
|
335
|
+
for path in sorted(find_repos(root)):
|
|
336
|
+
readme = next((path / n for n in README_NAMES if (path / n).is_file()), None)
|
|
337
|
+
text = readme.read_text(encoding="utf-8", errors="replace") if readme else ""
|
|
338
|
+
result.append((path, readme_summary(text), _local_last_commit(path)))
|
|
339
|
+
return result
|
|
340
|
+
|
|
341
|
+
|
|
342
|
+
def run_list(
|
|
343
|
+
*,
|
|
344
|
+
root: Path | None,
|
|
345
|
+
org: str | None,
|
|
346
|
+
github_org: str | None = None,
|
|
347
|
+
local: bool = False,
|
|
348
|
+
fast: bool = False,
|
|
349
|
+
as_json: bool = False,
|
|
350
|
+
pat: str | None = None,
|
|
351
|
+
) -> None:
|
|
352
|
+
"""`bdt list-repo`: print every repo with its last commit date and description.
|
|
353
|
+
|
|
354
|
+
Lists `org`'s Azure DevOps repos and/or `github_org`'s GitHub repos; with neither (or with
|
|
355
|
+
`local`) lists the clones under `root` (default `work_dir()`) instead.
|
|
356
|
+
"""
|
|
357
|
+
entries: list[dict[str, str]]
|
|
358
|
+
if local or not (org or github_org):
|
|
359
|
+
search_root = root or work_dir()
|
|
360
|
+
if not search_root.is_dir():
|
|
361
|
+
sys.exit(
|
|
362
|
+
f"Local work dir {search_root} doesn't exist. Set AZDO_WORK_DIR (or BMS_WORK_DIR) to "
|
|
363
|
+
"where your repos are cloned, or pass --root."
|
|
364
|
+
)
|
|
365
|
+
if not local:
|
|
366
|
+
print("No org configured (AZDO_ORG / GITHUB_ORG or --org / --github-org): listing local clones.", file=sys.stderr)
|
|
367
|
+
entries = [{"name": p.name, "location": str(p), **_commit_fields(c), "description": d} for p, d, c in list_local(search_root)]
|
|
368
|
+
labels = [e["location"] for e in entries]
|
|
369
|
+
else:
|
|
370
|
+
remote = list_remote(org=org, github_org=github_org, pat=pat, fast=fast)
|
|
371
|
+
entries = [
|
|
372
|
+
{
|
|
373
|
+
"project": r.project,
|
|
374
|
+
"name": r.name,
|
|
375
|
+
"source": r.source,
|
|
376
|
+
"url": r.remote_url,
|
|
377
|
+
**_commit_fields(r.last_commit),
|
|
378
|
+
"description": r.description,
|
|
379
|
+
}
|
|
380
|
+
for r in remote
|
|
381
|
+
]
|
|
382
|
+
labels = [f"{r.project}/{r.name}" for r in remote]
|
|
383
|
+
|
|
384
|
+
if as_json:
|
|
385
|
+
print(json.dumps(entries, indent=2, ensure_ascii=False))
|
|
386
|
+
return
|
|
387
|
+
# Descriptions and authors are remote-controlled text: don't let them drive the terminal (JSON above keeps them verbatim).
|
|
388
|
+
labels = [_printable(label) for label in labels]
|
|
389
|
+
authors = [_printable(e["last_commit_author"]) for e in entries]
|
|
390
|
+
label_w, author_w = max(map(len, labels), default=0), max(map(len, authors), default=0)
|
|
391
|
+
for label, author, e in zip(labels, authors, entries):
|
|
392
|
+
commit = f"{e['last_commit_date'][:10]:<10} {e['last_commit_id'][:8]:<8} {author:<{author_w}}"
|
|
393
|
+
print(f"{label:<{label_w}} {commit} {_printable(e['description'])}".rstrip())
|
|
394
|
+
|
|
395
|
+
|
|
396
|
+
def _printable(text: str) -> str:
|
|
397
|
+
"""`text` with control characters (ESC, tabs, newlines, ...) replaced by spaces."""
|
|
398
|
+
return "".join(c if c.isprintable() else " " for c in text)
|
|
399
|
+
|
|
400
|
+
|
|
401
|
+
def _commit_fields(c: CommitInfo) -> dict[str, str]:
|
|
402
|
+
return {"last_commit_id": c.id, "last_commit_date": c.date, "last_commit_author": c.author}
|
|
171
403
|
|
|
172
404
|
|
|
173
405
|
def clone(remote_url: str, dest: Path, auth: dict[str, str] | None = None) -> subprocess.CompletedProcess:
|
|
@@ -48,7 +48,7 @@ from .pr_markdown import build_attachments_section, build_comment_content, build
|
|
|
48
48
|
# (needed for the draft mutations), `body` the PR description.
|
|
49
49
|
PR_VIEW_FIELDS = "number,title,baseRefName,headRefName,mergeable,statusCheckRollup,isDraft,state"
|
|
50
50
|
# What `bdt pr info` needs on top of the check rollup: where to link to, and the issues GitHub says it closes.
|
|
51
|
-
PR_INFO_FIELDS = "number,title,url,state,isDraft,closingIssuesReferences,statusCheckRollup"
|
|
51
|
+
PR_INFO_FIELDS = "number,title,url,state,isDraft,mergeable,baseRefName,closingIssuesReferences,statusCheckRollup"
|
|
52
52
|
|
|
53
53
|
# GitHub has no API for uploading images to a PR description (only the web
|
|
54
54
|
# UI's drag-and-drop, which needs a browser session). The standard
|
|
@@ -15,7 +15,7 @@ from .ado_auth import AdoAuthError, ado_session
|
|
|
15
15
|
from .cli_tools import EXIT_NEEDS_APPROVAL, HTTP_TIMEOUT_SECS, PollHeartbeat, WaitDeadline, detect_agent_session, ensure_agent_session_note, exit_wait_timeout, is_claude_code, status_rerun_cmd
|
|
16
16
|
from .gitrepo import AdoRemote, current_branch, head_commit_subject
|
|
17
17
|
from .pr_create_args import PrCreateOptions
|
|
18
|
-
from . import pr_cancel
|
|
18
|
+
from . import pr_cancel, pr_drift
|
|
19
19
|
from .pr_choice import PrCandidate, choose_pr
|
|
20
20
|
from .pr_markdown import build_attachments_section, build_comment_content, build_screenshots_section
|
|
21
21
|
|
|
@@ -152,6 +152,32 @@ def merge_conflict_message(pr: dict) -> str | None:
|
|
|
152
152
|
return f"PR #{pr_id} ({title!r}) {detail} (mergeStatus={merge_status})"
|
|
153
153
|
|
|
154
154
|
|
|
155
|
+
def target_tip(session: requests.Session, remote: AdoRemote, target: str) -> str | None:
|
|
156
|
+
"""The commit branch `target` points at now; None if there is no such branch."""
|
|
157
|
+
r = session.get(
|
|
158
|
+
f"{_base_url(remote)}/_apis/git/repositories/{quote(remote.repo, safe='')}/refs",
|
|
159
|
+
params={"filter": f"heads/{target}", "api-version": "7.1"},
|
|
160
|
+
timeout=HTTP_TIMEOUT_SECS,
|
|
161
|
+
)
|
|
162
|
+
r.raise_for_status()
|
|
163
|
+
return next((ref["objectId"] for ref in r.json().get("value", []) if ref.get("name") == f"refs/heads/{target}"), None)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
def target_drift(session: requests.Session, remote: AdoRemote, pr: dict) -> pr_drift.Drift | None:
|
|
167
|
+
"""`pr_drift.check` for `pr`: has its target branch moved since Azure DevOps computed `mergeStatus`, and does it still merge?
|
|
168
|
+
Raises `requests.RequestException` when the target's tip can't be looked up: callers decide what "unknown" means for them."""
|
|
169
|
+
moved = pr_drift.moved_target(pr)
|
|
170
|
+
return pr_drift.check(remote, pr, target_tip(session, remote, moved[0])) if moved else None
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
def target_drift_or_none(session: requests.Session, remote: AdoRemote, pr: dict) -> pr_drift.Drift | None:
|
|
174
|
+
"""`target_drift`, best effort like `has_build_policy`: an extra check mustn't fail a status, so None when it can't be made."""
|
|
175
|
+
try:
|
|
176
|
+
return target_drift(session, remote, pr)
|
|
177
|
+
except requests.RequestException:
|
|
178
|
+
return None
|
|
179
|
+
|
|
180
|
+
|
|
155
181
|
def draft_notice(pr: dict) -> str | None:
|
|
156
182
|
"""None if the PR isn't a draft; else a heads-up that it is.
|
|
157
183
|
|
|
@@ -1225,6 +1251,7 @@ def run(
|
|
|
1225
1251
|
baseline_completed_ids[def_id] = max(baseline_completed_ids.get(def_id, 0), b["id"])
|
|
1226
1252
|
|
|
1227
1253
|
draft_notice_shown = False
|
|
1254
|
+
drift_notice_shown: str | None = None
|
|
1228
1255
|
policy_checked = False
|
|
1229
1256
|
heartbeat = PollHeartbeat()
|
|
1230
1257
|
deadline = WaitDeadline(timeout)
|
|
@@ -1243,6 +1270,13 @@ def run(
|
|
|
1243
1270
|
pr_number = pr["pullRequestId"]
|
|
1244
1271
|
pr_title = pr.get("title", "?")
|
|
1245
1272
|
pr_status = pr.get("status", "?")
|
|
1273
|
+
# every poll, so a target that moves mid-wait is noticed too; one cheap request, the merge itself only when something changed
|
|
1274
|
+
drift = target_drift_or_none(session, remote, pr)
|
|
1275
|
+
if drift and drift.conflicting:
|
|
1276
|
+
sys.exit(pr_drift.conflict_message(pr, drift))
|
|
1277
|
+
if drift and (drift_msg := pr_drift.notice(drift)) != drift_notice_shown:
|
|
1278
|
+
print(("\n" if wait else "") + drift_msg)
|
|
1279
|
+
drift_notice_shown = drift_msg
|
|
1246
1280
|
if pr_status == "abandoned":
|
|
1247
1281
|
# nothing will ever build for it: say so (and why) instead of polling on with --wait
|
|
1248
1282
|
print(f"PR #{pr_number}: {pr_title} ({pr_status})")
|