Skip to content

Commit 79da2ca

Browse files
authored
Make the minimum required git version a placeholder in the error text (#4778)
- **PR Description** 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.
2 parents a52d953 + 05b27c3 commit 79da2ca

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

pkg/app/app.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,15 +140,22 @@ func NewApp(config config.AppConfigurer, test integrationTypes.IntegrationTest,
140140
return app, nil
141141
}
142142

143+
const minGitVersionStr = "2.32.0"
144+
145+
func minGitVersionErrorMessage(tr *i18n.TranslationSet) string {
146+
return fmt.Sprintf(tr.MinGitVersionError, minGitVersionStr)
147+
}
148+
143149
func (app *App) validateGitVersion() (*git_commands.GitVersion, error) {
144150
version, err := git_commands.GetGitVersion(app.OSCommand)
145151
// if we get an error anywhere here we'll show the same status
146-
minVersionError := errors.New(app.Tr.MinGitVersionError)
152+
minVersionError := errors.New(minGitVersionErrorMessage(app.Tr))
147153
if err != nil {
148154
return nil, minVersionError
149155
}
150156

151-
if version.IsOlderThan(2, 32, 0) {
157+
minRequiredVersion, _ := git_commands.ParseGitVersion(minGitVersionStr)
158+
if version.IsOlderThanVersion(minRequiredVersion) {
152159
return nil, minVersionError
153160
}
154161

pkg/app/errors.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ type errorMapping struct {
1616
func knownError(tr *i18n.TranslationSet, err error) (string, bool) {
1717
errorMessage := err.Error()
1818

19-
knownErrorMessages := []string{tr.MinGitVersionError}
19+
knownErrorMessages := []string{minGitVersionErrorMessage(tr)}
2020

2121
if lo.Contains(knownErrorMessages, errorMessage) {
2222
return errorMessage, true

pkg/i18n/english.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1717,7 +1717,7 @@ func EnglishTranslationSet() *TranslationSet {
17171717
CreateNewBranchFromCommit: "Create new branch off of commit",
17181718
BuildingPatch: "Building patch",
17191719
ViewCommits: "View commits",
1720-
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.",
1720+
MinGitVersionError: "Git version must be at least %s. Please upgrade your git version.",
17211721
RunningCustomCommandStatus: "Running custom command",
17221722
SubmoduleStashAndReset: "Stash uncommitted submodule changes and update",
17231723
AndResetSubmodules: "And reset submodules",

0 commit comments

Comments
 (0)