Skip to content

Publishing Wiki content fails if there’s nothing to commit #172

@johlju

Description

@johlju

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.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions