Skip to content

chore(i18n): fix lunaria pre-commit hook with force: true#2528

Merged
ghostdevv merged 1 commit intonpmx-dev:mainfrom
romansp:lunaria-force-skip-cache
Apr 15, 2026
Merged

chore(i18n): fix lunaria pre-commit hook with force: true#2528
ghostdevv merged 1 commit intonpmx-dev:mainfrom
romansp:lunaria-force-skip-cache

Conversation

@romansp
Copy link
Copy Markdown
Contributor

@romansp romansp commented Apr 14, 2026

🔗 Linked issue

Fixes #2527.

🧭 Context

This resolves issue where lunaria cache becomes stale after rebasing or merging, which causes lunaria to crash and fail git pre-commit hook. Instead configure lunaria to bypass git caching and always read the latest commit from git history.

📚 Description

Configures force: true when creating lunaria instance to bypass git commit cache.

Here's what I found from investigating this issue.

Lunaria by default uses a cache, stored in ./node_modules/.cache/lunaria, to keep track of the latest commit hash per locale file, like this:

{
  "i18n/locales/en.json":"696d036a75e005e33f7b86bf11e52459de0530ac",
  "i18n/locales/ar-EG.json":"eb4d86207ad164d008eabd0c2864e99773a4e223",
  "i18n/locales/az-AZ.json":"95c2aae90923665f74c91e80de3de1b3e426999a",
  // ...
}

This cache is reused between builds (or calls to lunaria instance in git pre-commit hook). Cache helps to skip looking into older commits when looking for the latest commit for each locale file. But this cache can become stale, for example after rebase operations.

For example, you made a change in locale file, committed, cache updated. Then imagine you rebased your branch, hashes change. This causes lunaria to fail to find that last commit in git database.

When this happens lunaria just aborts process completely instead of throwing, so we can't even capture this error to retry.

Discord thread: https://discord.com/channels/1464542801676206113/1493012869174923476

)

This resolves issue where lunaria cache becomes stale after rebasing or merging, which causes lunaria to crash and fail git pre-commit hook. Instead configure lunaria to bypass git caching and always read the latest commit from git history.
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 14, 2026

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Apr 14, 2026 8:02pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Apr 14, 2026 8:02pm
npmx-lunaria Ignored Ignored Apr 14, 2026 8:02pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 14, 2026

📝 Walkthrough

Walkthrough

The Lunaria initialization in lunaria.ts has been updated to pass a configuration object with force: true to the createLunaria function. This configuration change bypasses git caching mechanisms, ensuring the latest commit data is always read directly from git history rather than using cached values.

Changes

Cohort / File(s) Summary
Lunaria Initialisation Configuration
lunaria/lunaria.ts
Updated createLunaria() invocation to pass a configuration object containing force: true, which disables git caching and forces reading of current commit data from git history. Resolves instances where the hook fails on tracked files lacking commits in the working branch.
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code changes directly address the requirement in issue #2527 by configuring force: true to bypass git caching and prevent failures from stale cache entries.
Out of Scope Changes check ✅ Passed All changes are scoped to the Lunaria initialization in lunaria/lunaria.ts and directly address the issue requirements without introducing unrelated modifications.
Description check ✅ Passed The pull request description clearly explains the issue with stale Lunaria cache after rebasing and the solution of setting force: true to bypass caching.
Title check ✅ Passed The title accurately reflects the main change: adding force: true to the Lunaria configuration to fix the pre-commit hook issue.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 14, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ All tests successful. No failed tests found.

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Member

@MatteoGabriele MatteoGabriele left a comment

Choose a reason for hiding this comment

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

Thanks for this one. I've encountered it many times!

@ghostdevv ghostdevv self-requested a review April 15, 2026 10:20
@MatteoGabriele MatteoGabriele added this pull request to the merge queue Apr 15, 2026
@ghostdevv ghostdevv removed this pull request from the merge queue due to a manual request Apr 15, 2026
@ghostdevv ghostdevv changed the title chore(i18n): configure force: true for lunaria instance (#2527) chore(i18n): fix lunaria pre-commit hook with force: true Apr 15, 2026
@ghostdevv
Copy link
Copy Markdown
Contributor

just tweaked the title :p

@ghostdevv ghostdevv added this pull request to the merge queue Apr 15, 2026
Merged via the queue into npmx-dev:main with commit 609a391 Apr 15, 2026
24 checks passed
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.

Pre-commit lunaria hook fails failing to find any commits for locale file

3 participants