Add PR title conventional commit versioning for pr-label - #34
Add PR title conventional commit versioning for pr-label#34ben-vaughan-nttd wants to merge 3 commits into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
aarti-joshi-nttd
left a comment
There was a problem hiding this comment.
PR Review: Add PR title conventional commit versioning for pr-label (#34)
Repo: launchbynttdata/launch-ado-automatic-versioner
Author: ben-vaughan-nttd
Branch: feat/pr-title-conventional-commit-versioning → main
What This PR Does Well
- Clean separation of concerns:
prtitleresolver,pipelinewarning helper, andexitcodesare all new, independently testable packages with solid unit test coverage (valid/invalid titles, breaking-change footer, scoped titles, fallback behavior). resolveBumpIntent/resolveFromBranchrefactor inprlabel.Servicekeeps the existing branch-mapping path intact while cleanly layering the new PR-title path on top — good backward compatibility.- Documentation (README, copilot-instructions, CHANGELOG) is updated in the same PR and is thorough, including a new exit-code table and a commented pipeline snippet.
Fixes Required
Blocking
No blocking issues found.
Non-Blocking
| # | File & Line | Issue |
|---|---|---|
| 1 | internal/cli/root.go:521-540 (mapPRLabelError) |
Exit-code classification relies on strings.Contains matching against formatted error text ("getting pull request title", "listing pr labels", "adding pr label") instead of sentinel errors. This is brittle — any future change to the wrapping message text in service.go will silently reclassify an ADO API failure (exit 2) as a generic config error (exit 1) without any compiler/test signal. Consider exporting typed/sentinel errors from prlabel (or wrapping with exitcodes.WrapADOAPI at the call sites in service.go directly) instead of matching on message text. |
| 2 | internal/cli/root.go:490-494 |
The emitted ##vso[task.logissue type=warning;] message appends ": PR title %q is not a conventional commit" whenever result.PRTitle is non-empty — which is effectively always true in the fallback path (the title is fetched before parsing). This means the documented exact string Semver calculation fallback to branch name (README.md, copilot-instructions.md) is rarely what's actually emitted. Either update the docs to show the real format, or keep the emitted line matching the documented constant and log the extra detail via zap.Warn only (which already happens). |
| 3 | internal/cli/root.go (newPRLabelCommand) |
--allow-branch-name-fallback without --use-pr-title is silently accepted and has no effect (the flag is only consulted inside the cfg.UsePRTitle branch of resolveBumpIntent). Since the docs state it only applies "with --use-pr-title", consider validating this combination and returning a config error instead of silently ignoring it. |
| 4 | internal/services/prlabel/service.go:974-980 |
fmt.Errorf("%w: %v", prtitle.ErrInvalidConventionalCommit, err) double-wraps the sentinel, since err returned from prtitles.Resolve already wraps ErrInvalidConventionalCommit. This produces a redundant message (e.g. "invalid conventional commit: invalid conventional commit: ..."). Consider just returning err directly since errors.Is checks in mapPRLabelError will still succeed. |
| 5 | internal/services/prlabel/service.go:982-989 |
The branchErr != nil fallback path is effectively unreachable: Apply already guarantees branch is non-empty whenever UsePRTitle && AllowBranchNameFallback, and that's the only error resolveFromBranch can return. Either add a code comment noting this is defensive/unreachable, or simplify given the invariant is enforced earlier. |
| 6 | internal/cli/root.go:435-441 |
if allowBranchFallbackFlag != nil is dead code — the flag is unconditionally bound via bindBoolFlag before RunE executes, so it's never nil. Minor readability cleanup. |
Overall Recommendation: comment_only
PR Review (additional feedback)Recommendation: Approve with minor comments — no new blockers beyond what's already been raised. Additional non-blocking items1.
Without this, a future refactor of 2. Exit code Service tests assert Same gap for the fallback path writing 3. Structured exit codes are effectively
That may be intentional for this PR, but worth a one-line note in CHANGELOG/README ("structured exit codes currently apply to 4. Document PR-title vs PR-description scope
Worth documenting explicitly:
That sets correct expectations for teams adopting 5. Custom / non-enumerated commit types are rejected
Calling that out avoids surprise when someone uses e.g. 6. Invalid-title failure path could log the attempted title When 7. The new ADO method is covered indirectly via What I'm not re-raising@aarti-joshi-nttd already covered: sentinel vs string-matched errors, pipeline warning text vs docs, silent OverallArchitecture and backward compatibility look good; domain/service tests are solid; CI is green. The items above are mostly test coverage, docs precision, and operability — good follow-ups before or right after merge. |
aarti-joshi-nttd
left a comment
There was a problem hiding this comment.
No blocking issues found. Detailed review comments posted separately.
Co-authored-by: Cursor <cursoragent@cursor.com>
Review feedback addressed (
|
rabindra-yadav-nttd
left a comment
There was a problem hiding this comment.
Approving
The latest update addresses the previous review feedback:
- Rejects
--allow-branch-name-fallbackunless--use-pr-titleis enabled. - Adds tests for semantic, Azure DevOps API, and configuration exit codes.
- Adds coverage for the exact Azure Pipelines fallback warning.
- Replaces brittle error-message matching with the typed
ErrADOAPIerror. - Clarifies that structured exit codes currently apply to
pr-label. - Documents the recommended
!syntax for breaking changes in Azure DevOps PR titles.
I also verified that:
go test -race ./...passes.- All GitHub checks pass, including builds across supported platforms, linting, security, vulnerability scanning, and tests.
git diff --checkreports no formatting issues.
The implementation now has appropriate validation, error classification, documentation, and test coverage. I found no remaining blocking issues.
Approved.
Summary
--use-pr-title/AAV_USE_PR_TITLEto derive semver bump intent from conventional commit PR titles (parsed viagithub.com/leodido/go-conventionalcommits).--allow-branch-name-fallback/AAV_ALLOW_BRANCH_NAME_FALLBACKto fall back to branch-prefix mapping when the title is invalid, with loud logging and Azure Pipelines##vso[task.logissue type=warning;]output.3) and document PR-title mode in README and copilot instructions.Test plan
go test ./...aav pr-label --use-pr-titleagainst a test PR with a conventional commit titleaav pr-label --use-pr-title --allow-branch-name-fallbackwith an invalid title and confirm pipeline warning outputMade with Cursor