Skip to content

Commit

Permalink
fixes dsccommunity#84 & removes --quiet
Browse files Browse the repository at this point in the history
  • Loading branch information
phbits committed Jun 27, 2021
1 parent c75f492 commit 4bfebe9
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 28 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Converted to public function.
- Updated to use `System.Diagnostics.Process` for improved error handling.
- Returns object, allowing caller to process result.
- `git` commands no longer use `--quiet` to populate returned object.

### Fixed

- `Publish_GitHub_Wiki_Content`
- Output message if `$GitHubToken` not specified which skips this task.
Fixes [Issue 75](https://github.com/dsccommunity/DscResource.DocGenerator/issues/75)
- `Invoke-Git`
- Set `$TimeOut` to Milliseconds
Fixes [Issue 84](https://github.com/dsccommunity/DscResource.DocGenerator/issues/84)

## [0.8.3] - 2021-04-10

Expand Down
8 changes: 4 additions & 4 deletions source/Public/Invoke-Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
The path to the git working directory.
.PARAMETER Timeout
Seconds to wait for process to exit.
Milliseconds to wait for process to exit.
.PARAMETER Arguments
The arguments to pass to the Git executable.
Expand All @@ -20,9 +20,9 @@
Invokes the Git executable to clone the specified repository to the working directory.
.EXAMPLE
Invoke-Git -WorkingDirectory 'C:\SomeDirectory' -Arguments @( 'status' ) -TimeOut 10
Invoke-Git -WorkingDirectory 'C:\SomeDirectory' -Arguments @( 'status' ) -TimeOut 10000
Invokes the Git executable to return the status while having a 10 second timeout.
Invokes the Git executable to return the status while having a 10000 millisecond timeout.
#>

function Invoke-Git
Expand All @@ -37,7 +37,7 @@ function Invoke-Git

[Parameter(Mandatory = $false)]
[System.Int32]
$TimeOut = 120,
$TimeOut = 120000,

[Parameter(ValueFromRemainingArguments = $true)]
[System.String[]]
Expand Down
8 changes: 4 additions & 4 deletions source/Public/Publish-WikiContent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ function Publish-WikiContent
Write-Verbose -Message ($script:localizedData.CloneWikiGitRepoMessage -f $WikiRepoName)

$gitCloneResult = Invoke-Git -WorkingDirectory $tempPath.FullName `
-Arguments @( 'clone', $wikiRepoName, $tempPath, '--quiet' )
-Arguments @( 'clone', $wikiRepoName, $tempPath )

if ($gitCloneResult.ExitCode -eq 0)
{
Expand Down Expand Up @@ -152,7 +152,7 @@ function Publish-WikiContent
Write-Verbose -Message ($localizedData.CommitAndTagRepoChangesMessage -f $ModuleVersion)

$gitCommitResult = Invoke-Git -WorkingDirectory $tempPath.FullName `
-Arguments @( 'commit', '--message', "`"$($localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"", '--quiet' )
-Arguments @( 'commit', '--message', "`"$($localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"" )

if ($gitCommitResult.ExitCode -eq 0)
{
Expand All @@ -162,10 +162,10 @@ function Publish-WikiContent
Write-Verbose -Message $localizedData.PushUpdatedRepoMessage

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
-Arguments @( 'push', 'origin', '--quiet' )
-Arguments @( 'push', 'origin' )

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
-Arguments @( 'push', 'origin', $ModuleVersion, '--quiet' )
-Arguments @( 'push', 'origin', $ModuleVersion )

Write-Verbose -Message $localizedData.PublishWikiContentCompleteMessage
}
Expand Down
30 changes: 10 additions & 20 deletions tests/unit/public/Publish-WikiContent.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,7 @@ InModuleScope $script:moduleName {
Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'commit' -and
$Arguments[1] -eq '--message' -and
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $mockPublishWikiContentParameters.ModuleVersion)`"" -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $mockPublishWikiContentParameters.ModuleVersion)`""
} -Exactly -Times 0 -Scope It

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
Expand All @@ -123,15 +122,13 @@ InModuleScope $script:moduleName {

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'push' -and
$Arguments[1] -eq 'origin' -and
$Arguments[2] -eq '--quiet'
$Arguments[1] -eq 'origin'
} -Exactly -Times 0 -Scope It

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'push' -and
$Arguments[1] -eq 'origin' -and
$Arguments[2] -eq $mockPublishWikiContentParameters.ModuleVersion -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq $mockPublishWikiContentParameters.ModuleVersion
} -Exactly -Times 0 -Scope It

Assert-MockCalled -CommandName Remove-Item -Exactly -Times 1 -Scope It
Expand Down Expand Up @@ -216,8 +213,7 @@ InModuleScope $script:moduleName {
Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'commit' -and
$Arguments[1] -eq '--message' -and
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $mockPublishWikiContentParameters.ModuleVersion)`"" -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $mockPublishWikiContentParameters.ModuleVersion)`""
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
Expand All @@ -230,15 +226,13 @@ InModuleScope $script:moduleName {

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'push' -and
$Arguments[1] -eq 'origin' -and
$Arguments[2] -eq '--quiet'
$Arguments[1] -eq 'origin'
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'push' -and
$Arguments[1] -eq 'origin' -and
$Arguments[2] -eq $mockPublishWikiContentParameters.ModuleVersion -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq $mockPublishWikiContentParameters.ModuleVersion
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Remove-Item -Exactly -Times 1 -Scope It
Expand Down Expand Up @@ -270,8 +264,7 @@ InModuleScope $script:moduleName {
} -ParameterFilter {
$Arguments[0] -eq 'commit' -and
$Arguments[1] -eq '--message' -and
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`"" -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $ModuleVersion)`""
}
}

Expand Down Expand Up @@ -337,8 +330,7 @@ InModuleScope $script:moduleName {
Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'commit' -and
$Arguments[1] -eq '--message' -and
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $mockPublishWikiContentParameters.ModuleVersion)`"" -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq "`"$($localizedData.UpdateWikiCommitMessage -f $mockPublishWikiContentParameters.ModuleVersion)`""
} -Exactly -Times 1 -Scope It

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
Expand All @@ -351,15 +343,13 @@ InModuleScope $script:moduleName {

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'push' -and
$Arguments[1] -eq 'origin' -and
$Arguments[2] -eq '--quiet'
$Arguments[1] -eq 'origin'
} -Exactly -Times 0 -Scope It

Assert-MockCalled -CommandName Invoke-Git -ParameterFilter {
$Arguments[0] -eq 'push' -and
$Arguments[1] -eq 'origin' -and
$Arguments[2] -eq $mockPublishWikiContentParameters.ModuleVersion -and
$Arguments[3] -eq '--quiet'
$Arguments[2] -eq $mockPublishWikiContentParameters.ModuleVersion
} -Exactly -Times 0 -Scope It

Assert-MockCalled -CommandName Remove-Item -Exactly -Times 1 -Scope It
Expand Down

0 comments on commit 4bfebe9

Please sign in to comment.