fix: update deployment run links#273
Conversation
There was a problem hiding this comment.
Code Review
This pull request refactors the deployment run link generation logic by moving it from cmd/deploy/deploy.go into a new helper function DeploymentRunLinkForRun in internal/hyphenApp/hyphenApp.go, and adds comprehensive unit tests. Feedback on these changes suggests passing the models.Deployment and models.DeploymentRun structs by pointer rather than by value to avoid inefficient copying and potential runtime panics from dereferencing a nil pointer.
There was a problem hiding this comment.
Pull request overview
This PR updates how the CLI constructs deployment run links by routing them through internal/hyphenApp, preferring the newer project/environment run route when the deployment (or run snapshot) contains enough metadata, and falling back to the legacy deployment route otherwise.
Changes:
- Added
DeploymentRunLinkhelpers ininternal/hyphenAppthat build project/environment run URLs when available, with a legacy/deploy/.../runs/...fallback. - Updated
cmd/deployto use the centralized link builder instead of formatting the legacy URL inline. - Added unit tests covering alternate IDs, ID fallbacks, legacy fallbacks, and snapshot-vs-selected deployment selection.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| internal/hyphenApp/hyphenApp.go | Centralizes deployment run link generation and adds logic for project/environment routes with fallback. |
| internal/hyphenApp/hyphenApp_test.go | Adds unit coverage for the new URL selection and fallback behavior. |
| cmd/deploy/deploy.go | Switches deploy output to use the new run link builder. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
related: https://github.com/Hyphen/hyphen-app/pull/1335
Summary
internal/hyphenAppinstead of formatting the legacy deployment URL inline.Impact
Deployment commands now return app links that match the project/environment run route when enough metadata is available, while keeping the existing deployment URL fallback for incomplete payloads.
Validation
env HOME=/private/tmp/hx-test-home GOCACHE=/private/tmp/hx-go-cache GOMODCACHE=/Users/nathanyoung/go/pkg/mod go test ./cmd/deploy ./internal/hyphenAppNote:
go test ./...was also attempted. The sandboxed run first hit Go build-cache permissions, then an isolated-home run passed acceptance coverage but failedinternal/oauthbecauseTestStartOAuthServercould not start its local OAuth callback server in this environment.