Skip to content

feat(dash-spv): log version with git commit for dev builds#770

Open
xdustinface wants to merge 2 commits into
v0.42-devfrom
feat/version-log
Open

feat(dash-spv): log version with git commit for dev builds#770
xdustinface wants to merge 2 commits into
v0.42-devfrom
feat/version-log

Conversation

@xdustinface
Copy link
Copy Markdown
Collaborator

@xdustinface xdustinface commented May 15, 2026

Add a build.rs that captures the git commit, a dirty flag, and whether HEAD is at a v* release tag, exposed through a version_info() helper next to VERSION. DashSpvClient::new() logs it once on creation. Tagged clean builds render just dash-spv <version>, while development builds include the commit (with a -dirty marker for uncommitted changes) so they are recognizable as non-release. Falls back to the bare version when git is unavailable, such as packaged builds.

Summary by CodeRabbit

  • Chores
    • Build now captures Git metadata (short commit, dirty/tagged status) and includes it in the app version.
    • Library exposes version info that includes commit details; release builds show a simplified version string.
    • Client logs the version info at startup.
  • Tests
    • Added unit tests verifying version formatting for release and non-release builds.

Review Change Stack

Add a `build.rs` that captures the git commit, a dirty flag, and whether `HEAD` is at a `v*` release tag, exposed through a `version_info()` helper next to `VERSION`. `DashSpvClient::new()` logs it once on creation. Tagged clean builds render just `dash-spv <version>`, while development builds include the commit (with a `-dirty` marker for uncommitted changes) so they are recognizable as non-release. Falls back to the bare version when git is unavailable, such as packaged builds.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 1a5276cf-83f5-43f2-9078-03d386e090aa

📥 Commits

Reviewing files that changed from the base of the PR and between 3db9924 and a142e65.

📒 Files selected for processing (1)
  • dash-spv/build.rs
🚧 Files skipped from review as they are similar to previous changes (1)
  • dash-spv/build.rs

📝 Walkthrough

Walkthrough

Adds a build script that captures git commit hash, dirty state, and tag status at compile time; exposes them as public constants and a version_info() formatter; the client logs the formatted version string during initialization.

Changes

Version metadata capture and reporting

Layer / File(s) Summary
Build-time git metadata extraction
dash-spv/build.rs
Build script runs git commands to capture short commit hash, dirty working tree status (excluding untracked files), and exact version tag match; emits DASH_SPV_GIT_HASH, DASH_SPV_GIT_DIRTY, DASH_SPV_GIT_TAGGED and cargo:rerun-if-changed entries for Git paths.
Library version constants and formatting
dash-spv/src/lib.rs
Adds pub const GIT_HASH, pub const GIT_DIRTY, pub const GIT_TAGGED, a const_str_eq helper, pub fn version_info() -> String for human-readable version formatting, and unit tests validating release vs non-release formatting and the "-dirty" suffix.
Client-side version logging
dash-spv/src/client/lifecycle.rs
DashSpvClient::new now logs an info-level message containing crate::version_info() during client construction.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I nibble at commits and tags so fine,
I fetch the hash, a dozen chars in line,
If the tree is messy I whisper "-dirty" too,
The client logs the tale for users to view,
🐇 Small rabbit builds, with versioned glue.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding git commit logging to version info in development builds.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/version-log

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.

❤️ Share

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

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 `@dash-spv/build.rs`:
- Around line 27-31: The build script only watches HEAD/index/packed-refs but
misses the concrete branch ref when HEAD is a symbolic ref; update the logic
around the git(...) calls (the loop using git(&["rev-parse", "--git-path",
path])) to also resolve HEAD's symbolic name and emit a cargo:rerun-if-changed
for that ref file: call git(&["rev-parse", "--symbolic-full-name", "HEAD"]) (or
similar) to get the refs/heads/<branch> name when present, then call
git(&["rev-parse", "--git-path", "<that-ref>"]) and println! the resulting path
so the build will rerun when the active branch ref changes; keep existing
behavior for index/packed-refs.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: db34b0fd-6559-4de4-8879-7cfbe3cb0164

📥 Commits

Reviewing files that changed from the base of the PR and between cfb01fa and 3db9924.

📒 Files selected for processing (3)
  • dash-spv/build.rs
  • dash-spv/src/client/lifecycle.rs
  • dash-spv/src/lib.rs

Comment thread dash-spv/build.rs
`.git/HEAD` only changes when switching branches, not when committing on the current one, so watching `HEAD`/`index`/`packed-refs` could leave `DASH_SPV_GIT_HASH` stale across metadata-driven rebuilds. Also watch the symbolic HEAD target's ref file.

Addresses CodeRabbit review comment on PR #770
#770 (comment)
@codecov
Copy link
Copy Markdown

codecov Bot commented May 15, 2026

Codecov Report

❌ Patch coverage is 48.38710% with 16 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.67%. Comparing base (bbf0a9c) to head (a142e65).
⚠️ Report is 1 commits behind head on v0.42-dev.

Files with missing lines Patch % Lines
dash-spv/src/lib.rs 46.66% 16 Missing ⚠️
Additional details and impacted files
@@              Coverage Diff              @@
##           v0.42-dev     #770      +/-   ##
=============================================
+ Coverage      72.62%   72.67%   +0.05%     
=============================================
  Files            320      321       +1     
  Lines          70254    70364     +110     
=============================================
+ Hits           51022    51139     +117     
+ Misses         19232    19225       -7     
Flag Coverage Δ
core 76.30% <ø> (ø)
ffi 49.16% <ø> (+0.75%) ⬆️
rpc 20.00% <ø> (ø)
spv 89.84% <48.38%> (-0.13%) ⬇️
wallet 71.27% <ø> (-0.01%) ⬇️
Files with missing lines Coverage Δ
dash-spv/src/client/lifecycle.rs 77.94% <100.00%> (+0.11%) ⬆️
dash-spv/src/lib.rs 46.66% <46.66%> (ø)

... and 8 files with indirect coverage changes

@github-actions github-actions Bot added the ready-for-review CodeRabbit has approved this PR label May 15, 2026
@xdustinface xdustinface requested a review from ZocoLini May 16, 2026 11:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review CodeRabbit has approved this PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant