Change how the git CLI subprocess is executed #684
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Your checklist for this pull request
馃毃Please review the guidelines for contributing to this repository.
TODO
Issue #687 was opened to track that this gem does not work on JRuby for Windows when using JDK > 8. This PR will be merged without this issue being solved.
Waiting for the following issues to be addressed:
Description
Fixes the following issues:
In the current implementation, all calls to
git
are done using backticks which has several disadvantages:Requirements
Implement a cross platform (Windows, Linux, and Mac) and cross Ruby (MRI, JRuby, and TruffleRuby) solution that meets the following requirements:
git
command subprocess that does not change these global variables in the process that this gem is running ingit
command without being interpreted by the system shellAlternative Implementations Examined
Option 6 was chosen because it is the least complex implementation that implements all the requirements.
Changes Made in this PR
This PR re-implements
Git::Lib#command
. In order to get the desired results, some changes were needed to the signature of this method which caused some changes in code and tests.The implementation of
Git::Lib#command
is handled by the new classGit::CommandLine
. This class has a small interface:#initialize
which accepts attribute values that do not change between git command invocations (env, binary_path, global_opts, and logger) and#run
which takes the git command args, redirection, and flags for normalization, chomping, and merging stderr with stdout.