Skip to content

Fix version parsing #605

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

Merged
merged 1 commit into from
Jan 12, 2023
Merged

Fix version parsing #605

merged 1 commit into from
Jan 12, 2023

Conversation

jcouball
Copy link
Member

Signed-off-by: James Couball jcouball@yahoo.com

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.

Description

FIXES #604

If git was built from source, the version output from the git version command is as follows:

$ git version
git version 2.39.GIT
$

In this case, calling Git::Lib#current_command_version causes the following error whenever the a Git::Lib object is created:

../.local/share/gem/ruby/3.0.0/gems/git-1.13.0/lib/git/lib.rb:1034:in current_command_version': undefined method split' for nil:NilClass (NoMethodError)

This PR relaxes the requirement such that a version number of '2.39.GIT' returns a version array [2, 39, 0].

The following changes were made in this PR:

  • Git::Lib.warn_if_old_command is no longer called when a Git::Lib object is created. Instead, it is called when a command is executed. This helps testing since a Git::Lib object can be created without calling an external command. This means that the message displayed on STDERR when your version of Git is too old is delayed until you explicitly try tot run a git command.
  • The regex used to parse the output of git version was changed to require only two numeric version components and will pad the resulting version array with zeros. For example, if git version outputs git version 2.39.GIT, then calling Git::Lib#current_command_version will return [2, 39, 0].
  • Tests were added to test Git::Lib#current_command_veresion

Signed-off-by: James Couball <jcouball@yahoo.com>
@jcouball jcouball force-pushed the fix_version_parsing branch from 8ddd04c to ca26ca9 Compare January 12, 2023 21:07
@jcouball jcouball merged commit 23a0ac4 into master Jan 12, 2023
@jcouball jcouball deleted the fix_version_parsing branch January 12, 2023 21:15
@jcouball jcouball mentioned this pull request Jan 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

failure using git built from source
1 participant