diff --git a/CHANGELOG.md b/CHANGELOG.md index 81d5af28..fa2f80fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Remove ModuleBuilder patch. - Remove install DSC step on Linux. +### Fixed + +- `Publish-WikiContent` + - Check if git command is successful. Fixes [#172](https://github.com/dsccommunity/DscResource.DocGenerator/issues/172). + ## [0.13.0] - 2025-02-28 ### Removed diff --git a/source/Public/Publish-WikiContent.ps1 b/source/Public/Publish-WikiContent.ps1 index 682b2c94..efd168f4 100644 --- a/source/Public/Publish-WikiContent.ps1 +++ b/source/Public/Publish-WikiContent.ps1 @@ -163,25 +163,33 @@ function Publish-WikiContent Invoke-Git -WorkingDirectory $tempPath ` -Arguments @( 'remote', 'set-url', 'origin', "https://$($GitUserName):$($GitHubAccessToken)@github.com/$OwnerName/$RepositoryName.wiki.git" ) + Write-Verbose -Message $script:localizedData.AddWikiContentToGitRepoMessage - Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'add', '*' ) + $gitAddResult = Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'add', '*' ) -PassThru - Write-Verbose -Message ($script:localizedData.CommitAndTagRepoChangesMessage -f $ModuleVersion) + if ($gitAddResult.ExitCode -eq 1) + { + Write-Verbose -Message $script:localizedData.GitAddFailedMessage + } + else + { + Write-Verbose -Message ($script:localizedData.CommitAndTagRepoChangesMessage -f $ModuleVersion) - Invoke-Git -WorkingDirectory $tempPath ` - -Arguments @( 'commit', '--message', "`"$($script:localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"" ) + Invoke-Git -WorkingDirectory $tempPath ` + -Arguments @( 'commit', '--message', "`"$($script:localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"" ) - Write-Verbose -Message $script:localizedData.PushUpdatedRepoMessage + Write-Verbose -Message $script:localizedData.PushUpdatedRepoMessage - Invoke-Git -WorkingDirectory $tempPath ` - -Arguments @( 'tag', '--annotate', $ModuleVersion, '--message', $ModuleVersion ) + Invoke-Git -WorkingDirectory $tempPath ` + -Arguments @( 'tag', '--annotate', $ModuleVersion, '--message', $ModuleVersion ) - Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'push', 'origin' ) + Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'push', 'origin' ) - Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'push', 'origin', $ModuleVersion ) + Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'push', 'origin', $ModuleVersion ) - Write-Verbose -Message $script:localizedData.PublishWikiContentCompleteMessage + Write-Verbose -Message $script:localizedData.PublishWikiContentCompleteMessage + } } finally { diff --git a/source/en-US/DscResource.DocGenerator.strings.psd1 b/source/en-US/DscResource.DocGenerator.strings.psd1 index 22e88067..d5afc5d1 100644 --- a/source/en-US/DscResource.DocGenerator.strings.psd1 +++ b/source/en-US/DscResource.DocGenerator.strings.psd1 @@ -13,6 +13,7 @@ ConvertFrom-StringData @' ConfigLocalGitMessage = Configuring local Git settings. CloneWikiGitRepoMessage = Cloning the Wiki Git Repository '{0}'. AddWikiContentToGitRepoMessage = Adding the Wiki Content to the Git Repository. + GitAddFailedMessage = Adding Git changes failed, Wiki will not be updated. CommitAndTagRepoChangesMessage = Committing the changes to the Repository and adding build tag '{0}'. PushUpdatedRepoMessage = Pushing the updated Repository to the Git Wiki. PublishWikiContentCompleteMessage = Publish Wiki Content complete.