Fix metadata commit failing when files are identical#50
Merged
Conversation
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
MetadataService.UpdateAllAsyncstages the metadata files (VERSION.md,CHANGELOG.md,LICENSE.md, etc.) and then checksHasUncommittedChangesAsyncbefore committing. That check runsgit 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 addstages nothing) but some unrelated change exists in the working tree, the check returnstrue, thengit commitruns with nothing staged and fails with"nothing to commit". SinceCommitAsyncthrows on a non-zero exit, this errors the whole process.Fix
IGitService.HasStagedChangesAsync, implemented inGitServiceviagit diff --cached --name-only— this scopes the check to exactly whatgit commitwould commit.MetadataServicenow callsHasStagedChangesAsyncafter staging, so it only commits when the staged metadata files have actually changed and cleanly logs "No changes to commit" otherwise.MockGitServicetest 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