-
Notifications
You must be signed in to change notification settings - Fork 12
Description
Description:
When running the Publish-WikiContent.ps1 script, the process fails with an error if there are no changes to commit. The error occurs because git commit returns a non-zero exit code and the script throws, even when the working tree is clean. This leads to unnecessary build failures when no actual update is needed.
Steps to reproduce:
Run the Publish-WikiContent when there are no changes in the content to be published.
Observe that the script fails with the following error:
Code
git exit code: '1'
git standard output: 'On branch master
Your branch is up to date with 'origin/master'.
nothing to commit, working tree clean
'
Expected behavior:
The script should gracefully handle the scenario where there are no changes to commit, and avoid failing the publishing process.
Suggested Improvement:
Add a check for staged changes after git add, and only run git commit if changes exist. Alternatively, handle the specific "nothing to commit" output from git commit without throwing an error.
DscResource.DocGenerator/source/Public/Publish-WikiContent.ps1
Lines 166 to 175 in 985f3e9
| Write-Verbose -Message $script:localizedData.AddWikiContentToGitRepoMessage | |
| Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'add', '*' ) | |
| Write-Verbose -Message ($script:localizedData.CommitAndTagRepoChangesMessage -f $ModuleVersion) | |
| Invoke-Git -WorkingDirectory $tempPath ` | |
| -Arguments @( 'commit', '--message', "`"$($script:localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"" ) | |
| Write-Verbose -Message $script:localizedData.PushUpdatedRepoMessage |