Skip to content

Commit

Permalink
Invoke-Git: Fix new line in returned strings (#94)
Browse files Browse the repository at this point in the history
- `Invoke-Git`
  - No longer write a new line to the end of string for the returned properties
    `StandardOutput` and `StandardError`.
johlju authored Jul 8, 2021

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent df9cf25 commit dd65819
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -44,11 +44,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Enabled the function to extract the comment block if it is not at the top
of the script file to support composite resources.
- Updated code to pass newly added quality checks.
- `Invoke-Git`
- `Invoke-Git`
- 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.
- No longer write a new line to the end of string for the returned properties
`StandardOutput` and `StandardError`.

### Fixed

4 changes: 4 additions & 0 deletions source/Public/Invoke-Git.ps1
Original file line number Diff line number Diff line change
@@ -79,6 +79,10 @@ function Invoke-Git
$returnValue.ExitCode = $process.ExitCode
$returnValue.StandardOutput = $process.StandardOutput.ReadToEnd()
$returnValue.StandardError = $process.StandardError.ReadToEnd()

# Remove all new lines at end of string.
$returnValue.StandardOutput = $returnValue.StandardOutput -replace '[\r?\n]+$'
$returnValue.StandardError = $returnValue.StandardError -replace '[\r?\n]+$'
}
}
}

0 comments on commit dd65819

Please sign in to comment.