feat: set branch as alias on deploy command#8111
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughSummary by CodeRabbitRelease Notes
WalkthroughThis pull request adds support for propagating the Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes 🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/build.ts (1)
179-196: Logic looks correct; consider trimming the comment to focus on "why".The branch computation logic is sound. However, per coding guidelines, the comment includes portions that describe what the code does (e.g., "use the alias as the branch name", "we leave it undefined") which the variable names and ternary already convey. The valuable parts are the business reasons.
✏️ Suggested comment refinement
- // For non-production contexts, use the alias as the branch name so that - // branch-aware steps (e.g. DB setup) can create isolated resources for this - // deploy. In production, we leave it undefined so that `@netlify/config` - // resolves it from git as usual. + // Enables branch-aware steps (e.g. DB setup) to create isolated resources. + // Production leaves branch to `@netlify/config` to resolve from git. const isProductionContext = !context || context === 'production' const branch = isProductionContext ? undefined : alias || branchOptionAs per coding guidelines: "Never write comments on what the code does; make the code clean and self-explanatory instead."
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/build.ts` around lines 179 - 196, The comment above the branch computation is overly descriptive of what the code already expresses; update it to a concise "why" only. Replace the multi-sentence explanation around isProductionContext and branch with a short line that explains the business intent (e.g., that non-production contexts use an override to isolate resources while production leaves branch resolution to git/@netlify/config), and remove the parts that restate the ternary logic using the identifiers isProductionContext, context, alias, and branchOption.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/build.ts`:
- Around line 179-196: The comment above the branch computation is overly
descriptive of what the code already expresses; update it to a concise "why"
only. Replace the multi-sentence explanation around isProductionContext and
branch with a short line that explains the business intent (e.g., that
non-production contexts use an override to isolate resources while production
leaves branch resolution to git/@netlify/config), and remove the parts that
restate the ternary logic using the identifiers isProductionContext, context,
alias, and branchOption.
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@tests/unit/lib/build.test.ts`:
- Line 33: The test reveals RunBuildOptions missing a declared branch property
while the implementation returns branch: alias; update the type RunBuildOptions
to include an optional or required branch: string (or adjust the implementation
to stop returning branch) so the runtime shape matches the type. Locate the
RunBuildOptions type definition and add branch: string (or branch?: string)
accordingly, and ensure functions like the build runner that currently set
branch: alias (the code returning branch) conform to the updated type so tests
no longer need type assertions.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: c9916ae8-3f6b-4aec-8d1f-8aef98028550
📒 Files selected for processing (2)
src/lib/build.tstests/unit/lib/build.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- src/lib/build.ts
tests/unit/lib/build.test.ts
Outdated
| options: { alias: 'custom-alias' }, | ||
| }) | ||
|
|
||
| expect(result.branch).toBe('custom-alias') |
There was a problem hiding this comment.
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
# Description: Check RunBuildOptions type definition and getRunBuildOptions implementation
# Find RunBuildOptions type definition
ast-grep --pattern 'type RunBuildOptions = $_'
ast-grep --pattern 'interface RunBuildOptions { $$$ }'
# Check the getRunBuildOptions function return statement
rg -n "RunBuildOptions" --type ts -C 5 src/lib/build.ts
# Check if branch is being set in the implementation
rg -n "branch" --type ts src/lib/build.tsRepository: netlify/cli
Length of output: 2432
🏁 Script executed:
cd tests/unit/lib && wc -l build.test.tsRepository: netlify/cli
Length of output: 71
🏁 Script executed:
head -n 50 tests/unit/lib/build.test.ts | tail -n +25Repository: netlify/cli
Length of output: 715
🏁 Script executed:
sed -n '135,210p' src/lib/build.tsRepository: netlify/cli
Length of output: 2177
🏁 Script executed:
rg -n "import.*build" src/lib/build.ts | head -20Repository: netlify/cli
Length of output: 156
🏁 Script executed:
rg -n "from '@netlify/build'" src/lib/build.tsRepository: netlify/cli
Length of output: 156
🏁 Script executed:
rg -A 5 '@netlify/build' package.jsonRepository: netlify/cli
Length of output: 302
🏁 Script executed:
# Also check if there's a tsconfig.build.json to understand compilation setup
cat tsconfig.build.json 2>/dev/null | head -30Repository: netlify/cli
Length of output: 265
Update RunBuildOptions type to include the branch property.
The implementation returns branch: alias but the RunBuildOptions type does not declare this property. The test must use a type assertion workaround to access it. Either extend the type definition to include branch, or adjust the implementation to match the declared type.
🧰 Tools
🪛 GitHub Check: typecheck
[failure] 33-33:
Property 'branch' does not exist on type 'RunBuildOptions'.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@tests/unit/lib/build.test.ts` at line 33, The test reveals RunBuildOptions
missing a declared branch property while the implementation returns branch:
alias; update the type RunBuildOptions to include an optional or required
branch: string (or adjust the implementation to stop returning branch) so the
runtime shape matches the type. Locate the RunBuildOptions type definition and
add branch: string (or branch?: string) accordingly, and ensure functions like
the build runner that currently set branch: alias (the code returning branch)
conform to the updated type so tests no longer need type assertions.
|
What's the intent of this change @eduardoboucas? I believe alias and branch are intentionally distinct concepts, aren't they? https://cli.netlify.com/commands/deploy/#deploy states:
|
🤖 I have created a release *beep* *boop* --- ## [24.8.0](v24.7.0...v24.8.0) (2026-03-27) ### Features * set `branch` as `alias` on `deploy` command ([#8111](#8111)) ([c08644e](c08644e)) ### Bug Fixes * **deps:** bump node-forge from 1.3.2 to 1.4.0 ([#8114](#8114)) ([3fc2aec](3fc2aec)) * **deps:** bump yaml from 2.8.1 to 2.8.3 ([#8101](#8101)) ([e95762d](e95762d)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: token-generator-app[bot] <82042599+token-generator-app[bot]@users.noreply.github.com>
No description provided.