feat(boards): ✨ Implement azdo boards work-item relation show command - #333
Merged
Conversation
Introduce ParseURL/URLIdentity/IsVisualStudioHost plus ErrNotAzDO/ErrInvalidPath sentinels, consolidating dev.azure.com and *.visualstudio.com host/path parsing previously duplicated across repo.go and gitcredential. Strict mode rejects non-AzDO hosts and pathless URLs; lax mode is best-effort for forgiving fallbacks such as relation URL parsing. Foundation for subsequent refactors; no behavior change yet.
Table-driven coverage for strict and lax modes, both host styles, ssh host, nil and empty-host URLs, exact legacy error text, and errors.Is sentinels.
OrganizationFromURL, ProjectFromURL, and RepositoryFromURL now use azdo.ParseURL, removing duplicated host/path logic and the dead organization guard. Preserves exact legacy error text (invalid path %q) and hostname-matching behavior.
gitcredential delegates organization extraction to azdo.ParseURL and classifies ErrNotAzDO/ErrInvalidPath via errors.Is while preserving legacy error messages. Removes the last inline .visualstudio.com parsing outside internal/azdo.
Cover get-operation URL parsing: visualstudio.com subdomain, dev.azure.com path, missing path, non-AzDO host, wrong protocol, and missing token.
…ions util.Parse gains ParseOptions to reject organization-prefixed targets (used by relation add, which handles cross-org links via --target-url instead) and to accept bare IDs when the project is implied by scope. Overhauls ParseOptions and Parse docs with input grammar, examples, and error conditions.
Cover DisallowOrganization rejections, AllowBareTargets bare-ID resolution, and rejection of the legacy ORGANIZATION/PROJECT slash form.
Extracts organization and project from work-item URLs: subdomain for visualstudio.com hosts, first path segment for dev.azure.com, and the path segment directly before /_apis as project with first-segment fallback. Delegates organization extraction to azdo.ParseURL lax mode; best-effort to keep relation fallbacks forgiving.
Cover both host styles, the _apis project rule, first-segment fallback, and malformed/non-AzDO input.
Add RelationTarget, ResolveRelationTarget with dedup cache, FetchRelationTarget, and WorkItemIDFromURL to relation shared so cross-project target resolution is reusable by both add and the new show command.
Cover cache hit/miss and nil-cache behavior, fallback fetching, and non-work-item URL handling.
--target-id now accepts [PROJECT/]ID, with bare IDs resolving in the source project's scope; organization-prefixed forms are rejected and point to --target-url for cross-org links. Adds -T/--target-id and -u/--target-url shorthands and enforces BelongsToProject on both source and targets.
Cover bare-ID and PROJECT/ID target forms, org-prefix rejection, cross-project routing, and BelongsToProject enforcement on source and targets.
azdo boards work-item relation show [ORG:]PROJECT/ID lists a work item's relations with TYPE, ORGANIZATION, PROJECT, ID, and TITLE columns; --json emits the raw SDK work item. Fetches relation titles with per-ID dedup; artifact and remote links fall back to URL parsing. Alias: s.
Cover table rendering, remote-link fallback, artifact relations with empty ID, and JSON output.
Register show.NewCmd in the relation group alongside add and remove.
Document [PROJECT/]ID target syntax, -T/-u shorthands, and cross-org guidance.
Generated from the command's cobra help, including the --json and --format output options.
Add the show subcommand to the relation group listing.
Rebuild the full help reference so relation show appears in the command tree.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
azdo boards work-item relation showcommand: lists all relations of a single Azure Boards work item, mirroringaz boards work-item relation show. The work item is fetched withexpand=All, relationreferenceNames are replaced with friendly names, and results render as a table or JSON.Changes
show [ORG:]PROJECT/ID(aliass); table columns TYPE / ORGANIZATION / PROJECT / ID / TITLE;--jsonemits the raw SDK work item; relation titles fetched with per-ID dedup; artifact and remote links fall back to URL parsing.--target-idaccepts[PROJECT/]ID(bare IDs resolve in the source project scope); organization-prefixed forms rejected (cross-org links require--target-url); new-T/-ushorthands;BelongsToProjectenforced on source and targets.azdo.ParseURL/IsVisualStudioHost/ErrNotAzDO/ErrInvalidPathininternal/azdo;repo.goandgitcredentialmigrated onto it, removing duplicated host/path parsing while preserving legacy error text.util.ParsegainsDisallowOrganizationandAllowBareTargets; docs overhauled.ParseWorkItemURL(workitem/shared) and relation target resolution (ResolveRelationTarget,FetchRelationTarget,WorkItemIDFromURL) inrelation/shared, reused by add and show.Verification
go test ./... -count=1: 2341 passed in 178 packagesgo vet ./...: cleangolangci-lint(changed packages): cleangofumpt: cleanFixes #275