Skip to content

Feature/version and commit hash - #44

Open
CodeWithMa wants to merge 2 commits into
devfrom
feature/version-and-commit-hash
Open

Feature/version and commit hash#44
CodeWithMa wants to merge 2 commits into
devfrom
feature/version-and-commit-hash

Conversation

@CodeWithMa

@CodeWithMa CodeWithMa commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary by CodeRabbit

  • New Features

    • Added an About section in Settings displaying the application version and shortened commit identifier.
    • Application builds now include version and commit information for easier identification.
  • Bug Fixes

    • Ensured version and commit details are consistently available across web, desktop, container, and hosted builds.

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
@vercel

vercel Bot commented Jul 18, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
watch-list Ready Ready Preview, Comment Jul 18, 2026 3:05pm

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ba3dad0a-113b-4541-8e9c-60df6cee8948

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🧹 Nitpick comments (1)
Dockerfile (1)

17-18: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Parse package.json consistently.

The Pages workflow reads the version through Bun, but this Docker command parses JSON with grep and sed. The regex depends on the key layout and on there being one matching line. A package formatting change can produce an incorrect APP_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

📥 Commits

Reviewing files that changed from the base of the PR and between 621dc87 and f7eb501.

📒 Files selected for processing (10)
  • .github/workflows/deploy-pages.yml
  • Dockerfile
  • angular.json
  • docker-compose.prod.yml
  • src/app/components/settings/settings.component.spec.ts
  • src/app/components/settings/settings.component.ts
  • src/env.d.ts
  • src/environments/environment.tauri.ts
  • src/environments/environment.ts
  • src/environments/environment.web.ts

Comment thread angular.json
Comment on lines +34 to +37
"define": {
"import.meta.env.APP_COMMIT_HASH": "\"dev\"",
"import.meta.env.APP_VERSION": "\"0.0.0\""
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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

Comment on lines +161 to +163
get shortHash(): string {
return environment.commitHash?.substring(0, 7) ?? 'unknown';
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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'.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant