From 4172be6bc8f585d272c482de76ee4c05a9b6ed46 Mon Sep 17 00:00:00 2001 From: Simon Whitaker Date: Tue, 2 Jan 2024 18:22:08 +0000 Subject: [PATCH 1/2] Show a friendly error message when starting lazygit from a non-existent cwd Closes 3187 --- pkg/app/errors.go | 4 ++++ pkg/i18n/english.go | 2 ++ 2 files changed, 6 insertions(+) diff --git a/pkg/app/errors.go b/pkg/app/errors.go index 2561fccb8ef..02e9470e0c6 100644 --- a/pkg/app/errors.go +++ b/pkg/app/errors.go @@ -27,6 +27,10 @@ func knownError(tr *i18n.TranslationSet, err error) (string, bool) { originalError: "fatal: not a git repository", newError: tr.NotARepository, }, + { + originalError: "getwd: no such file or directory", + newError: tr.WorkingDirectoryDoesNotExist, + }, } if mapping, ok := lo.Find(mappings, func(mapping errorMapping) bool { diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index 80e89ceff0b..a7f4a0de446 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -335,6 +335,7 @@ type TranslationSet struct { StashIncludeUntrackedChanges string StashOptions string NotARepository string + WorkingDirectoryDoesNotExist string Jump string ScrollLeftRight string ScrollLeft string @@ -1120,6 +1121,7 @@ func EnglishTranslationSet() TranslationSet { InitialBranch: "Branch name? (leave empty for git's default): ", NoRecentRepositories: "Must open lazygit in a git repository. No valid recent repositories. Exiting.", IncorrectNotARepository: "The value of 'notARepository' is incorrect. It should be one of 'prompt', 'create', 'skip', or 'quit'.", + WorkingDirectoryDoesNotExist: "The current working directory does not exist", AutoStashTitle: "Autostash?", AutoStashPrompt: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)", StashPrefix: "Auto-stashing changes for ", From 0cdca9ac2c0e1e5adc7b8c83b42129ac6914c5d9 Mon Sep 17 00:00:00 2001 From: Simon Whitaker Date: Tue, 2 Jan 2024 18:43:39 +0000 Subject: [PATCH 2/2] Update error message --- pkg/i18n/english.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/i18n/english.go b/pkg/i18n/english.go index a7f4a0de446..b9ccc95dc7b 100644 --- a/pkg/i18n/english.go +++ b/pkg/i18n/english.go @@ -1121,7 +1121,6 @@ func EnglishTranslationSet() TranslationSet { InitialBranch: "Branch name? (leave empty for git's default): ", NoRecentRepositories: "Must open lazygit in a git repository. No valid recent repositories. Exiting.", IncorrectNotARepository: "The value of 'notARepository' is incorrect. It should be one of 'prompt', 'create', 'skip', or 'quit'.", - WorkingDirectoryDoesNotExist: "The current working directory does not exist", AutoStashTitle: "Autostash?", AutoStashPrompt: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)", StashPrefix: "Auto-stashing changes for ", @@ -1155,6 +1154,7 @@ func EnglishTranslationSet() TranslationSet { StashIncludeUntrackedChanges: "Stash all changes including untracked files", StashOptions: "Stash options", NotARepository: "Error: must be run inside a git repository", + WorkingDirectoryDoesNotExist: "Error: the current working directory does not exist", Jump: "Jump to panel", ScrollLeftRight: "Scroll left/right", ScrollLeft: "Scroll left",