ui-next: inject i18n, code-langs & version#1193
Conversation
Walkthrough
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 Checkov (3.3.8)packages/ui-next/package.jsonTraceback (most recent call last): 🔧 ESLint
ESLint install timed out. The project may have too many dependencies for the sandbox. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@packages/ui-next/index.ts`:
- Around line 135-142: Update fetchAddonVersion to request only the latest
commit by passing maxCount: 1 to git.log(), while preserving the existing hash
and dirty-status version construction.
🪄 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: 87cdd953-0823-41d1-a33b-17d49ec75b5b
📒 Files selected for processing (2)
packages/ui-next/index.tspackages/ui-next/package.json
| const fetchAddonVersion = async (name: string, addonPath: string) => { | ||
| try { | ||
| const git = simpleGit(addonPath); | ||
| const [log, status] = await Promise.all([git.log(), git.status()]); | ||
| if (log.all.length > 0) { | ||
| let hash = log.all[0].hash.substring(0, 7); | ||
| if (!status.isClean()) hash += '-dirty'; | ||
| versions[name] = versions[name] ? `${versions[name]}-${hash}` : hash; |
There was a problem hiding this comment.
🚀 Performance & Scalability | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
# Inspect the target file and nearby context
git ls-files packages/ui-next/index.ts packages/ui-next/package.json package.json
wc -l packages/ui-next/index.ts
sed -n '110,170p' packages/ui-next/index.ts
# Find simple-git usage/version in the repo
rg -n "simple-git|git\.log\(" packages/ui-next package.json packages -g '!**/dist/**' -g '!**/build/**'Repository: hydro-dev/Hydro
Length of output: 3811
🌐 Web query:
simple-git log maxCount option documentation
💡 Result:
In the simple-git library, the maxCount option within the git log method is used to limit the number of commits returned [1][2]. Specifying options.maxCount is functionally equivalent to passing the --max-count option directly to the underlying git log command [3][4]. You can use it by passing an options object to the log method, for example: git.log({ maxCount: 10 }); This configuration will instruct simple-git to retrieve only the most recent 10 commits [1][2]. The log method also supports various other options, including from and to for defining commit ranges, file for filtering by path, and custom formatting options [1][4].
Citations:
- 1: https://www.npmjs.com/package/simple-git
- 2: https://github.com/steveukx/git-js?sponsor=1
- 3: https://npmx.dev/package/simple-git/v/3.25.0
- 4: https://registry.npmjs.org/simple-git
Bound the git log query to one commit. git.log() reads the full history for each addon, but only the latest hash is used here. Use maxCount: 1 to avoid unnecessary startup and rebuild work.
Proposed fix
- const [log, status] = await Promise.all([git.log(), git.status()]);
+ const [log, status] = await Promise.all([git.log({ maxCount: 1 }), git.status()]);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| const fetchAddonVersion = async (name: string, addonPath: string) => { | |
| try { | |
| const git = simpleGit(addonPath); | |
| const [log, status] = await Promise.all([git.log(), git.status()]); | |
| if (log.all.length > 0) { | |
| let hash = log.all[0].hash.substring(0, 7); | |
| if (!status.isClean()) hash += '-dirty'; | |
| versions[name] = versions[name] ? `${versions[name]}-${hash}` : hash; | |
| const fetchAddonVersion = async (name: string, addonPath: string) => { | |
| try { | |
| const git = simpleGit(addonPath); | |
| const [log, status] = await Promise.all([git.log({ maxCount: 1 }), git.status()]); | |
| if (log.all.length > 0) { | |
| let hash = log.all[0].hash.substring(0, 7); | |
| if (!status.isClean()) hash += '-dirty'; | |
| versions[name] = versions[name] ? `${versions[name]}-${hash}` : hash; |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@packages/ui-next/index.ts` around lines 135 - 142, Update fetchAddonVersion
to request only the latest commit by passing maxCount: 1 to git.log(), while
preserving the existing hash and dirty-status version construction.
Summary by CodeRabbit