Skip to content

Commit

Permalink
Publish-WikiContent: Fix bug that prevents clone repo (#93)
Browse files Browse the repository at this point in the history
- `Publish-WikiContent`
  - Fixed bug that prevented the repo to be cloned.
  • Loading branch information
johlju authored Jul 8, 2021
1 parent d23d17d commit df9cf25
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 13 deletions.
5 changes: 3 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Output properties in return value if called with the `Debug` optional
common parameter.
- `Publish-WikiContent`
- Remove a unnecessary `Set-Location` so it is possible to remove the
- Remove a unnecessary `Set-Location` so it is possible to remove the
temporary folder.
- Fix code style in tests.
- Fixed code style in tests.
- Moved verbose statement so it is only outputted in the right context.
- Fixed bug that prevented the repo to be cloned.

## [0.8.3] - 2021-04-10

Expand Down
25 changes: 14 additions & 11 deletions source/Public/Publish-WikiContent.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,10 @@ function Publish-WikiContent

Write-Verbose -Message $script:localizedData.CreateTempDirMessage

$tempPath = New-TempFolder
$tempFolder = New-TempFolder

$tempPath = $tempFolder.FullName

$wikiRepoName = "https://github.com/$OwnerName/$RepositoryName.wiki.git"

try
Expand All @@ -109,13 +112,13 @@ function Publish-WikiContent
{
Write-Verbose -Message $script:localizedData.ConfigGlobalGitMessage

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
$null = Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'config', '--global', 'core.autocrlf', $GlobalCoreAutoCrLf )
}

Write-Verbose -Message ($script:localizedData.CloneWikiGitRepoMessage -f $WikiRepoName)

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

if ($gitCloneResult.ExitCode -eq 0)
Expand All @@ -133,36 +136,36 @@ function Publish-WikiContent

Write-Verbose -Message $script:localizedData.ConfigLocalGitMessage

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
$null = Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'config', '--local', 'user.email', $GitUserEmail )

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
$null = Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'config', '--local', 'user.name', $GitUserName )

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
$null = Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'remote', 'set-url', 'origin', "https://$($GitUserName):$($GitHubAccessToken)@github.com/$OwnerName/$RepositoryName.wiki.git" )

Write-Verbose -Message $localizedData.AddWikiContentToGitRepoMessage

$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
$null = Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'add', '*' )

Write-Verbose -Message ($localizedData.CommitAndTagRepoChangesMessage -f $ModuleVersion)

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

if ($gitCommitResult.ExitCode -eq 0)
{
$null = Invoke-Git -WorkingDirectory $tempPath.FullName `
$null = Invoke-Git -WorkingDirectory $tempPath `
-Arguments @( 'tag', '--annotate', $ModuleVersion, '--message', $ModuleVersion )

Write-Verbose -Message $localizedData.PushUpdatedRepoMessage

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

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

Write-Verbose -Message $localizedData.PublishWikiContentCompleteMessage
Expand Down

0 comments on commit df9cf25

Please sign in to comment.