-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update Invoke-Git to use System.Diagnostics.Process
- Loading branch information
Showing
8 changed files
with
524 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
<# | ||
.SYNOPSIS | ||
Invokes the git command. | ||
.PARAMETER WorkingDirectory | ||
The path to the git working directory. | ||
.PARAMETER Timeout | ||
Seconds to wait for process to exit. | ||
.PARAMETER Arguments | ||
The arguments to pass to the Git executable. | ||
.EXAMPLE | ||
Invoke-Git clone https://github.com/X-Guardian/xActiveDirectory.wiki.git --quiet | ||
Invokes the Git executable to clone the specified repository to the current working directory. | ||
#> | ||
|
||
function Invoke-Git | ||
{ | ||
[CmdletBinding()] | ||
[OutputType([System.Collections.Hashtable])] | ||
param | ||
( | ||
[Parameter(Mandatory = $true)] | ||
[System.String] | ||
$WorkingDirectory, | ||
|
||
[Parameter(Mandatory = $false)] | ||
[System.Int32] | ||
$TimeOut = 120, | ||
|
||
[Parameter(ValueFromRemainingArguments = $true)] | ||
[System.String[]] | ||
$Arguments | ||
) | ||
|
||
$returnValue = @{ | ||
'ExitCode' = -1 | ||
'StandardOutput' = '' | ||
'StandardError' = '' | ||
} | ||
|
||
$argumentsJoined = $Arguments -join ' ' | ||
|
||
# Trying to remove any access token from the debug output. | ||
if ($argumentsJoined -match ':[\d|a-f].*@') | ||
{ | ||
$argumentsJoined = $argumentsJoined -replace ':[\d|a-f].*@', ':RedactedToken@' | ||
} | ||
|
||
Write-Debug -Message ($localizedData.InvokingGitMessage -f $argumentsJoined) | ||
|
||
try | ||
{ | ||
$process = New-Object -TypeName System.Diagnostics.Process | ||
$process.StartInfo.Arguments = $Arguments | ||
$process.StartInfo.CreateNoWindow = $true | ||
$process.StartInfo.FileName = 'git.exe' | ||
$process.StartInfo.RedirectStandardOutput = $true | ||
$process.StartInfo.RedirectStandardError = $true | ||
$process.StartInfo.UseShellExecute = $false | ||
$process.StartInfo.WindowStyle = [System.Diagnostics.ProcessWindowStyle]::Hidden | ||
$process.StartInfo.WorkingDirectory = $WorkingDirectory | ||
|
||
if ($process.Start() -eq $true) | ||
{ | ||
if ($process.WaitForExit($TimeOut) -eq $true) | ||
{ | ||
$returnValue.ExitCode = $process.ExitCode | ||
$returnValue.StandardOutput = $process.StandardOutput.ReadToEnd() | ||
$returnValue.StandardError = $process.StandardError.ReadToEnd() | ||
} | ||
} | ||
} | ||
catch | ||
{ | ||
throw $_ | ||
} | ||
finally | ||
{ | ||
if ($process) | ||
{ | ||
$process.Dispose() | ||
} | ||
} | ||
|
||
return $returnValue | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,43 @@ | ||
# English strings | ||
ConvertFrom-StringData @' | ||
FoundMofFilesMessage = Found {0} MOF files in path '{1}'. | ||
GenerateHelpDocumentMessage = Generating help document for '{0}'. | ||
OutputHelpDocumentMessage = Outputting help document to '{0}'. | ||
GenerateWikiPageMessage = Generating wiki page for '{0}'. | ||
OutputWikiPageMessage = Outputting wiki page to '{0}'. | ||
NoDescriptionFileFoundWarning = No README.md description file found for '{0}', skipping. | ||
MultipleDescriptionFileFoundWarning = {1} README.md description files found for '{0}', skipping. | ||
NoExampleFileFoundWarning = No Example files found. | ||
CreateTempDirMessage = Creating a temporary working directory. | ||
ConfigGlobalGitMessage = Configuring global Git settings. | ||
ConfigLocalGitMessage = Configuring local Git settings. | ||
CloneWikiGitRepoMessage = Cloning the Wiki Git Repository '{0}'. | ||
AddWikiContentToGitRepoMessage = Adding the Wiki Content to the Git Repository. | ||
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. | ||
UpdateWikiCommitMessage = Updating Wiki with the content for module version '{0}'. | ||
NewTempFolderCreationError = Unable to create a temporary working folder in '{0}'. | ||
InvokingGitMessage = Invoking Git '{0}'. | ||
GenerateWikiSidebarMessage = Generating Wiki Sidebar '{0}'. | ||
GenerateWikiFooterMessage = Generating Wiki Footer '{0}'. | ||
CopyWikiFoldersMessage = Copying Wiki files from '{0}'. | ||
CopyFileMessage = Copying file '{0}' to the Wiki. | ||
AddFileToSideBar = Adding file '{0}' to the Wiki Sidebar. | ||
NothingToCommitToWiki = There are no changes to the documentation to commit and push to the Wiki. | ||
FoundClassBasedMessage = Found {0} class-based resources in the built module '{1}'. | ||
FoundClassResourcePropertyMessage = Found property '{0}' in the resource '{1}'. | ||
CommentBasedHelpMessage = Reading comment-based help from source file '{0}'. | ||
FoundResourceExamplesMessage = Found {0} examples. | ||
IgnoreAstParseErrorMessage = Errors was found during parsing of comment-based help. These errors were ignored: {0} | ||
FoundMofFilesMessage = Found {0} MOF files in path '{1}'. | ||
GenerateHelpDocumentMessage = Generating help document for '{0}'. | ||
OutputHelpDocumentMessage = Outputting help document to '{0}'. | ||
GenerateWikiPageMessage = Generating wiki page for '{0}'. | ||
OutputWikiPageMessage = Outputting wiki page to '{0}'. | ||
NoDescriptionFileFoundWarning = No README.md description file found for '{0}', skipping. | ||
MultipleDescriptionFileFoundWarning = {1} README.md description files found for '{0}', skipping. | ||
NoExampleFileFoundWarning = No Example files found. | ||
CreateTempDirMessage = Creating a temporary working directory. | ||
ConfigGlobalGitMessage = Configuring global Git settings. | ||
ConfigLocalGitMessage = Configuring local Git settings. | ||
CloneWikiGitRepoMessage = Cloning the Wiki Git Repository '{0}'. | ||
AddWikiContentToGitRepoMessage = Adding the Wiki Content to the Git Repository. | ||
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. | ||
UpdateWikiCommitMessage = Updating Wiki with the content for module version '{0}'. | ||
NewTempFolderCreationError = Unable to create a temporary working folder in '{0}'. | ||
InvokingGitMessage = Invoking Git '{0}'. | ||
GenerateWikiSidebarMessage = Generating Wiki Sidebar '{0}'. | ||
GenerateWikiFooterMessage = Generating Wiki Footer '{0}'. | ||
CopyWikiFoldersMessage = Copying Wiki files from '{0}'. | ||
CopyFileMessage = Copying file '{0}' to the Wiki. | ||
AddFileToSideBar = Adding file '{0}' to the Wiki Sidebar. | ||
NothingToCommitToWiki = There are no changes to the documentation to commit and push to the Wiki. | ||
FoundClassBasedMessage = Found {0} class-based resources in the built module '{1}'. | ||
FoundClassResourcePropertyMessage = Found property '{0}' in the resource '{1}'. | ||
ClassBasedCommentBasedHelpMessage = Reading comment-based help from source file '{0}'. | ||
FoundResourceExamplesMessage = Found {0} examples. | ||
IgnoreAstParseErrorMessage = Errors was found during parsing of comment-based help. These errors were ignored: {0} | ||
WikiGitCloneFailMessage = Failed to clone wiki. Ensure the feature is enabled and the first page has been created. | ||
WikiGitCloneFailMessageDebug = Wiki clone URL '{0}' | ||
InvokeGitStandardOutputMessage = git standard output: '{0}' | ||
InvokeGitStandardErrorMessage = git standard error: '{0}' | ||
InvokeGitExitCodeMessage = git exit code: '{0}' | ||
FoundCompositeFilesMessage = Found {0} composite files in path '{1}'. | ||
UnexpectedInvokeGitReturnCode = Unexpected return code '{0}'. Run with -Debug to see details. | ||
InvokeGitStandardOutputReturn = Git Standard Output: '{0}' | ||
InvokeGitStandardErrorReturn = Git Standard Error: '{0}' | ||
CommentBasedHelpBlockNotFound = A comment-based help block in source file '{0}' could not be found. | ||
CommentBasedHelpBlockNotAtTopMessage = A comment-based help block in source file '{0}' was found, but is not at the top of the file. | ||
CommentBasedHelpBlockNotAtTopMessage = A comment-based help block in source file '{0}' was found, but is not at the top ofthe file. | ||
CompositeResourceMultiConfigError = {1} composite resources were found in the source file '{0}'. This is not currently supported. Please separate these into different scripts. | ||
MacOSNotSupportedError = NotImplemented: MacOS is not supported for this operation because DSC can not be installed onto it. Please use an OS that DSC can be installed onto. | ||
'@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.