Skip to content

Log IHP source info at startup#2501

Open
amitaibu wants to merge 7 commits intomasterfrom
ihp-source-info
Open

Log IHP source info at startup#2501
amitaibu wants to merge 7 commits intomasterfrom
ihp-source-info

Conversation

@amitaibu
Copy link
Copy Markdown
Collaborator

Summary

  • Adds IHP.IDE.SourceInfo module that detects whether IHP runs from the nix store or a local checkout
  • Logs the source path, git branch, and commit at startup via Log.info (always visible, not gated behind DEBUG=1)
  • Example output: IHP Source: Local checkout (/home/user/IHP) on branch feature-x at commit abc1234

Test plan

  • Unit tests for formatSourceInfo covering all variants (NixStore, LocalCheckout with/without git info)
  • Manual: run devenv up with a local IHP checkout and verify the log line appears

🤖 Generated with Claude Code

Adds IHP.IDE.SourceInfo module that detects whether IHP is running from
the nix store or a local checkout, and logs the path, git branch, and
commit at startup so developers can quickly identify their IHP source.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@amitaibu amitaibu marked this pull request as draft March 11, 2026 14:14
amitaibu and others added 3 commits March 11, 2026 21:08
- Check if IHP_LIB path starts with /nix/store/ to correctly detect
  nix store vs local checkout (IHP_LIB is set in both scenarios)
- Move source info log above version log and gate both behind isDebugMode
- Use List.isPrefixOf for String comparisons to avoid type mismatches

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
IHP_LIB in nix store is a flat path like
/nix/store/abc123-ihp-env-var-backwards-compat, not a nested
ihp-ide/lib/IHP structure. Only navigate up 3 dirs for local checkouts.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Parse the project's flake.lock to extract the ihp input's branch
(original.ref) and revision (locked.rev), so nix store builds show
useful info like: IHP Source: Nix store (...) on branch main at revision abc123

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@amitaibu
Copy link
Copy Markdown
Collaborator Author

image

amitaibu and others added 3 commits March 11, 2026 21:36
- Rename `path` field to `checkoutPath` to avoid shadowing
- Fix stderr handle leak: use NoStream instead of CreatePipe
- Extract `parseFlakeLockJson` as pure function with dedicated tests
- Extract `makeSourceInfo` and `isNixStorePath` to reduce duplication
- Use `where` clauses instead of `let..in`
- Use Aeson.object/.= in tests instead of escaped JSON strings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Unify getSourceInfo/makeSourceInfo: resolve dir first, then call makeSourceInfo once
- Extract tryAnyNothing to deduplicate error handling in getFlakeLockInfo and getGitInfo
- Move SourceInfoSpec after MigrationGenerator in Test/Main.hs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@amitaibu amitaibu requested a review from mpscholten March 11, 2026 20:26
@amitaibu amitaibu marked this pull request as ready for review March 19, 2026 14:34
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