fix(configure): accept bare org name for --org#579
Conversation
Previously, �do-aw configure --org myorg would build malformed ADO API URLs because the value was used verbatim as the organization URL. When no usable ADO git remote is present (e.g. when the pipeline source lives in GitHub but runs in Azure DevOps), this made --definition-ids unusable without forcing users to pass the full https://dev.azure.com/myorg URL. Add a ormalize_org_url helper that: - prefixes the canonical https://dev.azure.com/ host when a bare org name is passed - rewrites the legacy {org}.visualstudio.com form to dev.azure.com/{org}`n- trims whitespace and trailing slashes Apply it in both branches of esolve_ado_context (override-on-ADO-remote and explicit-no-remote), update the --org CLI help text and docs/cli.md, and add unit tests covering bare names, full URLs, trailing slashes, legacy hosts, and whitespace. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
🔍 Rust PR ReviewSummary: Looks good — clean, focused fix with solid tests and documentation. Findings
|
Problem
ado-aw configure --org myorg --project Foo --definition-ids 2506fails because the bare org name is used verbatim as the ADO organization URL. Every API call ends up atmyorg/Foo/_apis/build/definitions/..., which is malformed.This bites users whose pipeline source lives in GitHub but whose pipeline runs in Azure DevOps. In that case
parse_ado_remotecorrectly rejects the GitHub remote and falls through to the(None, Some(org), Some(project))branch inresolve_ado_context, which stored--org's value unchanged.It was also a footgun even with an ADO remote: the
--orgoverride branch did the same thing.Fix
Add
normalize_org_url(&str) -> Stringand apply it in both branches ofresolve_ado_context. It:https://dev.azure.com/host when a bare org name is passed (no scheme, no slash, no dot){org}.visualstudio.comform todev.azure.com/{org}for consistency withparse_ado_remotehttps://dev.azure.com/{org}URLs untouchedThe CLI
--orghelp text anddocs/cli.mdare updated to advertise that both forms are accepted.Verification
After this change, the user's command works as expected:
is equivalent to
Tests
Five new unit tests in
src/configure.rscover:*.visualstudio.comrewriteAll 23 tests in
cargo test --bin ado-aw configure::pass.cargo buildis clean and no new clippy warnings are introduced insrc/configure.rs.