Skip to content

fix: use indexed commit in generated editor files - #1875

Closed
mikemikimike wants to merge 3 commits into
repowise-dev:mainfrom
mikemikimike:codex/fix-1874-indexed-commit
Closed

fix: use indexed commit in generated editor files#1875
mikemikimike wants to merge 3 commits into
repowise-dev:mainfrom
mikemikimike:codex/fix-1874-indexed-commit

Conversation

@mikemikimike

@mikemikimike mikemikimike commented Aug 23, 2026

Copy link
Copy Markdown

Summary

  • use the repository's stored head_commit when rendering the indexed commit in generated editor files
  • keep the existing live-HEAD fallback for legacy indexes without a stored commit
  • add regression coverage for the stored commit and seven-character display

Fixes #1874

Root cause

EditorFileDataFetcher.fetch() already loaded the Repository row but discarded its indexed head_commit and queried the checkout's current git HEAD. Rebases or later commits could therefore make the generated CLAUDE.md stamp describe a different commit than the index.

Validation

  • uv run --frozen pytest tests/unit/generation/test_editor_file_fetcher.py tests/unit/generation/test_editor_fetcher_helpers.py -q23 passed (136 Python 3.14 / pytest-asyncio deprecation warnings)
  • uv run --frozen ruff check packages/core/src/repowise/core/generation/editor_files/fetcher.py tests/unit/generation/test_editor_file_fetcher.py — passed
  • git diff --check — passed

The regression test exercises the real SQLAlchemy Repository object returned by the existing fixture and verifies the stored commit takes precedence over the live checkout fallback. No real LLM or external service is required.

@repowise-bot

repowise-bot Bot commented Aug 23, 2026

Copy link
Copy Markdown

✅ Health of changed files: 5.0 (unchanged)

📋 At a glance
2 hotspots touched · 2 files with recent fix history.

Files & modules (2)
  • packages (1 file)
    • .../editor_files/fetcher.py
  • tests (1 file)
    • .../generation/test_editor_file_fetcher.py

✅ Health gate: passed

📌 Before you merge

  • Run .../generation/test_editor_fetcher_helpers.py: they import the changed files
🔎 More signals (2)

🗺️ Change map

flowchart LR
  subgraph PR ["Changed in this PR (1 with dependents)"]
    f_packages_core_src_repowise_core_generation_editor_files_fetcher_py[".../editor_files/fetcher.py 🔥"]:::changed
  end
  f_packages_cli_src_repowise_cli_commands_status_cmd_py[".../commands/status_cmd.py"]
  f_packages_core_src_repowise_core_generation_editor_files_fetcher_py --> f_packages_cli_src_repowise_cli_commands_status_cmd_py
  f_packages_core_src_repowise_core_generation_editor_files___init___py[".../editor_files/__init__.py"]
  f_packages_core_src_repowise_core_generation_editor_files_fetcher_py --> f_packages_core_src_repowise_core_generation_editor_files___init___py
  t_tests_unit_generation_test_editor_fetcher_helpers_py(["✅ .../generation/test_editor_fetcher_helpers.py"]):::guard
  t_tests_unit_generation_test_editor_fetcher_helpers_py -.-> f_packages_core_src_repowise_core_generation_editor_files_fetcher_py
  classDef changed fill:#dbeafe,stroke:#1d4ed8,color:#1e3a5f
  classDef warn fill:#fef3c7,stroke:#b45309,color:#78350f
  classDef guard fill:#dcfce7,stroke:#15803d,color:#14532d
Loading

Solid arrows: code that imports the changed files (2 direct dependents, from the last indexed snapshot). Dashed: history/tests.

🔥 Hotspots touched (2)

  • .../editor_files/fetcher.py: 12 commits/90d, 4 dependents · primary owner: Raghav Chamadiya (88%)
  • .../generation/test_editor_file_fetcher.py: 3 commits/90d, 0 dependents · primary owner: Raghav Chamadiya (93%)

👀 Suggested reviewers @RaghavChamadiya


📊 See the full report for this PR
Your repo map with this PR's blast radius lit up, every caller of the contracts it changes, and health before and after. No sign-in. · ⭐ Star Repowise · 📥 Install bot · Silence on a single PR with [skip repowise] in the title · Per-repo toggle on repowise.dev/settings?tab=bot · Updated 2026-08-24 03:46 UTC

@mikemikimike
mikemikimike force-pushed the codex/fix-1874-indexed-commit branch from b56d9f6 to 4f39f33 Compare August 23, 2026 15:52
@RaghavChamadiya

Copy link
Copy Markdown
Member

Thanks @mikemikimike, you got to #1874 first and your read of it was right: the stamp has to come from repo.head_commit, not a shell-out for live HEAD.

I went with #1877 for this one, and it was close enough that I want to say why rather than leave you guessing. Three PRs landed on the same one-line change within a few hours, so the production diff did not separate them. What did was the fallback: head_commit can be NULL on an index built before that column was populated, which is why _get_head_short_sha stays as an or branch, and #1877 is the only one with a test pinning it. Without that test the fallback reads as dead code to whoever cleans up next.

One thing worth carrying forward. Your test sets head_commit to "indexed-commit-sha" and asserts the result is "indexed", which is the first seven characters of a string that is not a sha. It passes, but it would also pass if the truncation were wrong, since there is no real sha to truncate. A 40-character hex value asserted against its own [:7] tests the thing you actually changed.

Your #1881 is the trailing-glob fix I am taking over the other PR on that one, so this is not a pattern. Closing this as covered by #1877.

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.

[Bug] Generated CLAUDE.md stamps live HEAD instead of the commit the index was built against

2 participants