From 05b27c390d90bde277b2b49e6ca7581b4fe06629 Mon Sep 17 00:00:00 2001 From: Stefan Haller Date: Mon, 28 Jul 2025 13:10:25 +0200 Subject: [PATCH] Make the minimum required git version a placeholder in the error text This way we don't have to update the text and all translations every time we bump the version. Remove the year from the error text, it's cumbersome to update and I don't find it very important to have in the message. Also remove the invitation to file an issue; I don't find it very likely that we are going to relax the minimum git requirement again. --- pkg/app/app.go | 11 +++++++++-- pkg/app/errors.go | 2 +- pkg/i18n/english.go | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/pkg/app/app.go b/pkg/app/app.go index 914832b83..09b2236db 100644 --- a/pkg/app/app.go +++ b/pkg/app/app.go @@ -140,15 +140,22 @@ func NewApp(config config.AppConfigurer, test integrationTypes.IntegrationTest, return app, nil } +const minGitVersionStr = "2.32.0" + +func minGitVersionErrorMessage(tr *i18n.TranslationSet) string { + return fmt.Sprintf(tr.MinGitVersionError, minGitVersionStr) +} + func (app *App) validateGitVersion() (*git_commands.GitVersion, error) { version, err := git_commands.GetGitVersion(app.OSCommand) // if we get an error anywhere here we'll show the same status - minVersionError := errors.New(app.Tr.MinGitVersionError) + minVersionError := errors.New(minGitVersionErrorMessage(app.Tr)) if err != nil { return nil, minVersionError } - if version.IsOlderThan(2, 32, 0) { + minRequiredVersion, _ := git_commands.ParseGitVersion(minGitVersionStr) + if version.IsOlderThanVersion(minRequiredVersion) { return nil, minVersionError } diff --git a/pkg/app/errors.go b/pkg/app/errors.go index 02e9470e0..506fec276 100644 --- a/pkg/app/errors.go +++ b/pkg/app/errors.go @@ -16,7 +16,7 @@ type errorMapping struct { func knownError(tr *i18n.TranslationSet, err error) (string, bool) { errorMessage := err.Error() - knownErrorMessages := []string{tr.MinGitVersionError} + knownErrorMessages := []string{minGitVersionErrorMessage(tr)} if lo.Contains(knownErrorMessages, errorMessage) { return errorMessage, true diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 6eba8d5ef..49e796403 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1717,7 +1717,7 @@ func EnglishTranslationSet() *TranslationSet { CreateNewBranchFromCommit: "Create new branch off of commit", BuildingPatch: "Building patch", ViewCommits: "View commits", - MinGitVersionError: "Git version must be at least 2.32 (i.e. from 2021 onwards). Please upgrade your git version. Alternatively raise an issue at https://github.com/jesseduffield/lazygit/issues for lazygit to be more backwards compatible.", + MinGitVersionError: "Git version must be at least %s. Please upgrade your git version.", RunningCustomCommandStatus: "Running custom command", SubmoduleStashAndReset: "Stash uncommitted submodule changes and update", AndResetSubmodules: "And reset submodules",