Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invoke-Git: Fix new line in returned strings #94

Merged
merged 1 commit into from
Jul 8, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions source/Public/Invoke-Git.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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]+$'
}
}
}
Expand Down