Feature/version and commit hash - #44
Conversation
Inject APP_COMMIT_HASH and APP_VERSION at build time via Angular's define option, then display them in a new About section on the Settings page. - Add define defaults in angular.json (dev: "dev"/"0.0.0") - Add ImportMeta type declarations in src/env.d.ts - Add commitHash/appVersion to all environment files - Add About card showing version and short commit hash in Settings - Update CI workflow to pass --define flags with github.sha - Update Dockerfile with COMMIT_HASH build arg - Update docker-compose.prod.yml to pass build arg
- Replace node -e with bun -e in deploy-pages.yml for consistency - Add beforeEach/afterEach to safely save/restore environment in test - Remove inline cleanup that would be skipped on test failure
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
Dockerfile (1)
17-18: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick winParse
package.jsonconsistently.The Pages workflow reads the version through Bun, but this Docker command parses JSON with
grepandsed. The regex depends on the key layout and on there being one matching line. A package formatting change can produce an incorrectAPP_VERSION.Reuse a JSON parser so both build paths use the same metadata contract.
♻️ Proposed refactor
ARG COMMIT_HASH=unknown -RUN bun run build -- --define "import.meta.env.APP_COMMIT_HASH=\"$COMMIT_HASH\"" --define "import.meta.env.APP_VERSION=\"$(grep '"version"' package.json | sed 's/.*"\(.*\)".*/\1/')\"" +RUN bun run build -- --define "import.meta.env.APP_COMMIT_HASH=\"$COMMIT_HASH\"" --define "import.meta.env.APP_VERSION=\"$(bun -e 'console.log(require("./package.json").version)')\""Verify the Bun expression in the pinned builder image.
🤖 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 `@Dockerfile` around lines 17 - 18, Update the Docker build command’s APP_VERSION definition to read package.json through Bun’s JSON parser, matching the metadata expression used by the Pages workflow, and remove the grep/sed parsing. Verify the Bun expression is supported by the pinned builder image while preserving the existing APP_COMMIT_HASH definition.
🤖 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 `@angular.json`:
- Around line 34-37: Update the Tauri build path invoked by beforeBuildCommand
to inject the release APP_COMMIT_HASH and APP_VERSION values, matching the
existing define metadata used by the standard build; ensure Tauri artifacts
receive release metadata instead of the development defaults.
In `@src/app/components/settings/settings.component.ts`:
- Around line 161-163: Update the shortHash getter in SettingsComponent to treat
an empty commitHash as unavailable by using a truthiness-based fallback to
'unknown', while preserving the seven-character truncation for non-empty hashes.
Add a unit test covering an empty commit hash and asserting that shortHash
returns 'unknown'.
---
Nitpick comments:
In `@Dockerfile`:
- Around line 17-18: Update the Docker build command’s APP_VERSION definition to
read package.json through Bun’s JSON parser, matching the metadata expression
used by the Pages workflow, and remove the grep/sed parsing. Verify the Bun
expression is supported by the pinned builder image while preserving the
existing APP_COMMIT_HASH definition.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: 1f947a7c-543b-4af6-8fe9-ca4bb9c3100b
📒 Files selected for processing (10)
.github/workflows/deploy-pages.ymlDockerfileangular.jsondocker-compose.prod.ymlsrc/app/components/settings/settings.component.spec.tssrc/app/components/settings/settings.component.tssrc/env.d.tssrc/environments/environment.tauri.tssrc/environments/environment.tssrc/environments/environment.web.ts
| "define": { | ||
| "import.meta.env.APP_COMMIT_HASH": "\"dev\"", | ||
| "import.meta.env.APP_VERSION": "\"0.0.0\"" | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 5 \
'build:tauri|beforeBuildCommand|APP_COMMIT_HASH|APP_VERSION|--define' \
--glob 'package.json' \
--glob 'angular.json' \
--glob '*tauri*.json' \
--glob '*.yml' \
--glob '*.yaml' \
.Repository: CodeWithMa/watch-list
Length of output: 1948
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- angular.json ---'
cat -n angular.json | sed -n '1,110p'
printf '%s\n' '--- package.json ---'
cat -n package.json | sed -n '1,80p'
printf '%s\n' '--- Tauri and workflow references ---'
rg -n -C 6 \
'APP_COMMIT_HASH|APP_VERSION|build:tauri|beforeBuildCommand|production,tauri|git rev-parse|GITHUB_SHA|VERSION|version' \
src src-tauri .github package.json angular.json \
--glob '!**/node_modules/**' \
--glob '!**/dist/**'Repository: CodeWithMa/watch-list
Length of output: 50378
🏁 Script executed:
#!/bin/bash
set -euo pipefail
python3 - <<'PY'
from pathlib import Path
import re
for path in [Path("angular.json"), Path("package.json"), Path("src-tauri/tauri.conf.json")]:
print(f"--- {path} ---")
text = path.read_text()
for i, line in enumerate(text.splitlines(), 1):
if any(term in line for term in (
"define", "APP_COMMIT_HASH", "APP_VERSION",
"build:tauri", "beforeBuildCommand", "configuration",
"frontendDist", "devUrl"
)):
start = max(1, i - 8)
end = min(len(text.splitlines()), i + 8)
lines = text.splitlines()
for n in range(start, end + 1):
print(f"{n:4}: {lines[n-1]}")
print()
PY
printf '%s\n' '--- source metadata usage ---'
rg -n -C 8 'import\.meta\.env|APP_COMMIT_HASH|APP_VERSION|Watch List' src \
--glob '!**/node_modules/**'Repository: CodeWithMa/watch-list
Length of output: 12394
Inject metadata in the Tauri build path.
beforeBuildCommand runs bun run build:tauri without overriding APP_COMMIT_HASH or APP_VERSION. Tauri artifacts therefore display Watch List v0.0.0 (dev) instead of release metadata.
Add equivalent metadata injection to the Tauri build command or release workflow.
🤖 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 `@angular.json` around lines 34 - 37, Update the Tauri build path invoked by
beforeBuildCommand to inject the release APP_COMMIT_HASH and APP_VERSION values,
matching the existing define metadata used by the standard build; ensure Tauri
artifacts receive release metadata instead of the development defaults.
Source: MCP tools
| get shortHash(): string { | ||
| return environment.commitHash?.substring(0, 7) ?? 'unknown'; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
Treat an empty commit hash as unavailable.
?? 'unknown' does not handle ''. An empty build value makes shortHash return an empty string, so the About text renders empty parentheses instead of unknown.
Use a truthiness fallback and add a test for an empty hash.
🐛 Proposed fix
get shortHash(): string {
- return environment.commitHash?.substring(0, 7) ?? 'unknown';
+ return environment.commitHash?.substring(0, 7) || 'unknown';
}🤖 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 `@src/app/components/settings/settings.component.ts` around lines 161 - 163,
Update the shortHash getter in SettingsComponent to treat an empty commitHash as
unavailable by using a truthiness-based fallback to 'unknown', while preserving
the seven-character truncation for non-empty hashes. Add a unit test covering an
empty commit hash and asserting that shortHash returns 'unknown'.
Summary by CodeRabbit
New Features
Bug Fixes