Skip to content

Fix metadata commit failing when files are identical#50

Merged
matt-edmondson merged 1 commit into
mainfrom
claude/eager-gates-ogurG
May 29, 2026
Merged

Fix metadata commit failing when files are identical#50
matt-edmondson merged 1 commit into
mainfrom
claude/eager-gates-ogurG

Conversation

@matt-edmondson
Copy link
Copy Markdown
Contributor

Problem

MetadataService.UpdateAllAsync stages the metadata files (VERSION.md, CHANGELOG.md, LICENSE.md, etc.) and then checks HasUncommittedChangesAsync before committing. That check runs git status --porcelain, which reports changes across the entire working tree — not just the staged metadata files.

As a result, if the generated metadata files are identical to what's already committed (so git add stages nothing) but some unrelated change exists in the working tree, the check returns true, then git commit runs with nothing staged and fails with "nothing to commit". Since CommitAsync throws on a non-zero exit, this errors the whole process.

Fix

  • Add IGitService.HasStagedChangesAsync, implemented in GitService via git diff --cached --name-only — this scopes the check to exactly what git commit would commit.
  • MetadataService now calls HasStagedChangesAsync after staging, so it only commits when the staged metadata files have actually changed and cleanly logs "No changes to commit" otherwise.
  • Updated the MockGitService test fake to implement the new interface member.

Notes

The full solution build and tests could not be run in this sandbox: restore fails on a missing offline platform package (Microsoft.NETCore.App.Host.ubuntu.24.04-x64), and the IDE0055 formatting analyzer flags every line of every file (1448 pre-existing errors before this change, including unmodified files' copyright headers) due to an editorconfig/SDK mismatch in this environment. Both are environmental and unrelated to this change; the new code follows the surrounding tab-indented patterns exactly.

https://claude.ai/code/session_01CxXdwnwUfRwpY5MaEoNF2E


Generated by Claude Code

The metadata update checked HasUncommittedChangesAsync (git status
--porcelain) before committing, which reports changes across the entire
working tree rather than only the staged metadata files. If the generated
metadata files were identical to what was already committed (nothing
staged) but some unrelated change existed in the working tree, the check
returned true and 'git commit' ran with nothing staged, failing with
"nothing to commit" and erroring the whole process.

Add IGitService.HasStagedChangesAsync (git diff --cached --name-only) and
use it after staging so we only commit when the staged metadata files
actually changed.
@sonarqubecloud
Copy link
Copy Markdown

@matt-edmondson matt-edmondson merged commit c7845bf into main May 29, 2026
5 checks passed
@matt-edmondson matt-edmondson deleted the claude/eager-gates-ogurG branch May 29, 2026 05:40
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.

2 participants