From 213d2c217d6089c25f023d900ffb9ccffb48a1db Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Mon, 17 Nov 2025 17:52:33 +0000 Subject: [PATCH 1/4] Check return code --- source/Public/Publish-WikiContent.ps1 | 28 ++++++++++++------- .../DscResource.DocGenerator.strings.psd1 | 1 + 2 files changed, 19 insertions(+), 10 deletions(-) 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. From e13062c6ccb887eb35a9591d3bf1a014e042d7ff Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Mon, 17 Nov 2025 17:55:03 +0000 Subject: [PATCH 2/4] Check for non zero --- source/Public/Publish-WikiContent.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Public/Publish-WikiContent.ps1 b/source/Public/Publish-WikiContent.ps1 index efd168f4..48a18c85 100644 --- a/source/Public/Publish-WikiContent.ps1 +++ b/source/Public/Publish-WikiContent.ps1 @@ -168,7 +168,7 @@ function Publish-WikiContent $gitAddResult = Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'add', '*' ) -PassThru - if ($gitAddResult.ExitCode -eq 1) + if ($gitAddResult.ExitCode -ne 0) { Write-Verbose -Message $script:localizedData.GitAddFailedMessage } From cdedfb746e0b13b68faabcb92e133283b208e1b1 Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Mon, 17 Nov 2025 17:55:09 +0000 Subject: [PATCH 3/4] Update changelog --- CHANGELOG.md | 5 +++++ 1 file changed, 5 insertions(+) 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 From 727d4af3c5ddd4aed95578d0f069d123fcf020dc Mon Sep 17 00:00:00 2001 From: Daniel Hughes <2237515+dan-hughes@users.noreply.github.com> Date: Mon, 17 Nov 2025 18:03:36 +0000 Subject: [PATCH 4/4] Only check for 1 exitcode --- source/Public/Publish-WikiContent.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/Public/Publish-WikiContent.ps1 b/source/Public/Publish-WikiContent.ps1 index 48a18c85..efd168f4 100644 --- a/source/Public/Publish-WikiContent.ps1 +++ b/source/Public/Publish-WikiContent.ps1 @@ -168,7 +168,7 @@ function Publish-WikiContent $gitAddResult = Invoke-Git -WorkingDirectory $tempPath -Arguments @( 'add', '*' ) -PassThru - if ($gitAddResult.ExitCode -ne 0) + if ($gitAddResult.ExitCode -eq 1) { Write-Verbose -Message $script:localizedData.GitAddFailedMessage }