Skip to content

Change how the git CLI subprocess is executed #617

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

Closed
wants to merge 1 commit into from

Conversation

jcouball
Copy link
Member

@jcouball jcouball commented Feb 12, 2023

Your checklist for this pull request

🚨Please review the guidelines for contributing to this repository.

  • Ensure all commits include DCO sign-off.
  • Ensure that your contributions pass unit testing.
  • Ensure that your contributions contain documentation if applicable.

TODO

Waiting for the following issues to be addressed:

Description

Fixes #355, Fixes #363, Fixes #441, Fixes #495, Fixes #516, Fixes #574

In the current implementation, all calls to git are done using backticks which has several disadvantages:

  • STDOUT and STDERR are commingled (via redirection added to the command line using 2>&1) which can cause processing errors.
  • Changes to the environment's subprocess have to be global which could impact users of this gem
  • Arguments passed on the command line go through the system shell making it difficult to escape args correctly for all platforms AND leaving this gem open to security vulnerabilities

Desired Result

Implement a cross platform (Windows, Linux, and Mac) solution that can:

  • Independently capture STDOUT and STDERR
  • Stream STDOUT and STDERR to the terminal if needed for debugging
  • Provide a customized environment for the git command that does not impact users of this gem
  • Pass command line args to the git command without being interpreted by the system shell

What is Changed

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 class Git::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.

@jcouball jcouball force-pushed the git_cli_subprocess branch 10 times, most recently from e99bdab to d0c532f Compare February 19, 2023 19:26
@jcouball jcouball force-pushed the git_cli_subprocess branch 16 times, most recently from daa77a7 to 04ec6cd Compare February 28, 2023 15:27
@jcouball jcouball force-pushed the git_cli_subprocess branch 2 times, most recently from 5483fb6 to 37ea652 Compare March 2, 2023 16:28
@jcouball jcouball force-pushed the git_cli_subprocess branch from 45d9559 to 871ecf8 Compare March 9, 2023 18:20
@jcouball jcouball added v2.0.0 internal-change The PR includes changes that are NOT user facing and will NOT require a release labels Mar 9, 2023
@jcouball jcouball force-pushed the git_cli_subprocess branch from 871ecf8 to 19ba8db Compare March 10, 2023 01:08
@jcouball jcouball force-pushed the git_cli_subprocess branch 2 times, most recently from b66c852 to 075b83f Compare March 19, 2023 16:40
@jcouball jcouball force-pushed the git_cli_subprocess branch from 075b83f to 99a7e91 Compare April 1, 2023 20:46
@jcouball jcouball force-pushed the git_cli_subprocess branch 4 times, most recently from b7c32a6 to 4792172 Compare October 26, 2023 01:34
@jcouball jcouball mentioned this pull request Oct 26, 2023
3 tasks
@jcouball jcouball force-pushed the git_cli_subprocess branch 4 times, most recently from 298b335 to a081663 Compare January 1, 2024 18:44
@jcouball jcouball added major-change The PR includes incompatible API or functional changes and removed v2.0.0 internal-change The PR includes changes that are NOT user facing and will NOT require a release labels Jan 1, 2024
@jcouball jcouball force-pushed the git_cli_subprocess branch 4 times, most recently from 441b8e0 to ebfe7d2 Compare January 3, 2024 01:17
Signed-off-by: James Couball <jcouball@yahoo.com>
@jcouball jcouball force-pushed the git_cli_subprocess branch from ebfe7d2 to 62ff5cb Compare January 3, 2024 01:29
@jcouball jcouball mentioned this pull request Jan 13, 2024
3 tasks
@jcouball jcouball closed this Jan 14, 2024
@jcouball jcouball deleted the git_cli_subprocess branch March 20, 2024 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
major-change The PR includes incompatible API or functional changes
Projects
None yet
1 participant