Show a friendly error message when starting lazygit from a non-existent cwd

Closes 3187
This commit is contained in:
Simon Whitaker 2024-01-02 18:22:08 +00:00
parent d97b37a178
commit 4172be6bc8
2 changed files with 6 additions and 0 deletions

View file

@ -27,6 +27,10 @@ func knownError(tr *i18n.TranslationSet, err error) (string, bool) {
originalError: "fatal: not a git repository", originalError: "fatal: not a git repository",
newError: tr.NotARepository, newError: tr.NotARepository,
}, },
{
originalError: "getwd: no such file or directory",
newError: tr.WorkingDirectoryDoesNotExist,
},
} }
if mapping, ok := lo.Find(mappings, func(mapping errorMapping) bool { if mapping, ok := lo.Find(mappings, func(mapping errorMapping) bool {

View file

@ -335,6 +335,7 @@ type TranslationSet struct {
StashIncludeUntrackedChanges string StashIncludeUntrackedChanges string
StashOptions string StashOptions string
NotARepository string NotARepository string
WorkingDirectoryDoesNotExist string
Jump string Jump string
ScrollLeftRight string ScrollLeftRight string
ScrollLeft string ScrollLeft string
@ -1120,6 +1121,7 @@ func EnglishTranslationSet() TranslationSet {
InitialBranch: "Branch name? (leave empty for git's default): ", InitialBranch: "Branch name? (leave empty for git's default): ",
NoRecentRepositories: "Must open lazygit in a git repository. No valid recent repositories. Exiting.", 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'.", 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?", AutoStashTitle: "Autostash?",
AutoStashPrompt: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)", AutoStashPrompt: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)",
StashPrefix: "Auto-stashing changes for ", StashPrefix: "Auto-stashing changes for ",