-
Notifications
You must be signed in to change notification settings - Fork 12
Publish-WikiContent: Check if git command was successful
#173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
dan-hughes
wants to merge
4
commits into
dsccommunity:main
Choose a base branch
from
dan-hughes:fix-172
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
Git add guard has correctness gaps and doesn’t yet fix the “nothing to commit” failure from issue #172
A few points on this new block:
Exit code check is too narrow
1will be treated as “success” and still run commit/tag/push, even thoughgit addactually failed.Real git‑add failures are silently downgraded to verbose
Write-Verbose. With default settings this is invisible, while the comment/message says “Wiki will not be updated”.Write-Erroror a terminating error), not just silently skip the publish.Issue Publishing Wiki content fails if there’s nothing to commit #172 (“nothing to commit, working tree clean”) is not addressed
git commitreturns a non‑zero exit code when there’s nothing to commit, causingPublish-WikiContentto fail.git add *still exits0when there are no changes, so this guard does not prevent thegit commitinvocation from running in that scenario.Invoke-Gitis still called forcommitwithout-PassThru, so ifgit commitreturns1with “nothing to commit, working tree clean”, it will still throw and fail the build as before.To truly fix Publishing Wiki content fails if there’s nothing to commit #172 you need to short‑circuit before commit/tag/push when there are no staged changes, for example by using
git status --porcelainwith-PassThruand the existingNothingToCommitToWikilocalized message.Suggested direction
Consider something along these lines:
This way:
Please re‑run the scenario from issue #172 (no changes in the wiki repo) with this function to confirm that
Publish-WikiContentno longer fails when there is nothing to commit, and that genuine git errors are still visible to callers.I'll help you verify this review comment. Let me gather the necessary information by examining the codebase.
Now let me examine the actual codebase:
Now let me examine the actual file and verify the code exists:
🏁 Script executed:
Length of output: 1233
🏁 Script executed:
Length of output: 80
🏁 Script executed:
Length of output: 72
Let me continue verification with corrected search commands:
Now let me search for the Invoke-Git function and localized strings in the codebase:
🏁 Script executed:
Length of output: 477
🏁 Script executed:
Length of output: 2729
🏁 Script executed:
Length of output: 88
Now let me examine the Invoke-Git implementation more closely to understand -PassThru behavior:
🏁 Script executed:
Length of output: 2981
🏁 Script executed:
Length of output: 2778
🏁 Script executed:
Length of output: 1537
Exit code check is too narrow and doesn't prevent the "nothing to commit" failure from issue #172
The new code introduces several issues:
Exit code check only catches
1, not all failuresThe condition
if ($gitAddResult.ExitCode -eq 1)catches only exit code 1, but any other non-zero exit code fromgit addis silently treated as success and continues to the commit/tag/push block. This should be:Real git-add errors are only logged verbosely
When
git addfails with exit code 1, onlyWrite-Verboseis called. Since verbose output is disabled by default, actual git errors are invisible to callers. Error-level output should be used to surface real failures.The "nothing to commit" failure (Publishing Wiki content fails if there’s nothing to commit #172) is not prevented
The core issue remains unsolved:
git add *exits with code 0 even when there are no changes, so this guard doesn't short-circuit beforegit commit. Whengit commitruns and finds nothing to commit, it exits with code 1. Sincecommitis called without-PassThru,Invoke-Gitthrows, causing the function to fail—the exact Publishing Wiki content fails if there’s nothing to commit #172 problem.To fix this, detect when there are no staged changes before attempting commit. Use
git status --porcelainwith-PassThruand short-circuit gracefully:🤖 Prompt for AI Agents