-
Notifications
You must be signed in to change notification settings - Fork 8
Add minimum git version requirement check #39
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a minimum Git version requirement check to ensure users have Git 2.28.0 or later installed, which is necessary for sparse checkout functionality with the --filter option used by the application.
Changes:
- Added a new
Version.parse()method to parse plain version strings without a 'v' prefix - Replaced
is_git_installed()withget_git_version()that returns the installed Git version or None - Integrated version checking into the
check gitcommand to validate the minimum version requirement
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| app/utils/version.py | Added parse() method to parse plain version strings (e.g., '1.2.3') alongside existing parse_version_string() for 'v'-prefixed strings |
| app/utils/git.py | Introduced MIN_GIT_VERSION constant (2.28.0) and replaced boolean is_git_installed() with get_git_version() that extracts version from git --version output |
| app/commands/check/git.py | Updated git check command to retrieve git version, validate it meets minimum requirement, and display appropriate error messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
desmondwong1215
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I have tested it and it works as intended.
| if git_version is None: | ||
| error("Git is not installed") | ||
|
|
||
| info("Git is installed") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a small nit. I am ok with omitting the else clause to make a happy path, but will it be better if we add it for clarity and consistency, which is similar to lines 34 - 41?
if not config_user_name:
error(
f"You do not have {click.style('user.name', bold=True)} yet. Run {click.style('git config --global user.name <name>', bold=True, italic=True)}."
)
else:
info(
f"You have set {click.style('user.name', bold=True)} as {click.style(config_user_name, bold=True, italic=True)}"
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
error() does a sys.exit(1) call which stops the entire program.
I believe that the else is redundant for the other lines of code as well, generally we should keep the happy path prominent and not hide it in else clauses.
Do you think it would be better for me to remove the else in other lines instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But again, generally we don't want to touch code that isn't broken, so it should be a small issue, whether we decide to include or omit the else
Fixes git-mastery/git-mastery#60
git sparse-checkoutandgit clone <...> --sparseare features that are introduced in 2.25.0--filterin sparse checkout (which we use in app) is also not working until 2.28.0 (source: Sparse checkout not working with git version between 2.25 and 2.28 actions/checkout#1386)Would prefer not to set too strict restrictions on the git version (eg. must always be latest version, etc.) as additional features may not be required for the app, and thus it's not a requirement for users to update their git.