mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-04-27 12:32:37 +02:00
Show a friendly error message when starting lazygit from a non-existent cwd (#3192)
Closes #3187 - **PR Description** #3187 observes that lazygit crashes with a stack trace if it's run from a non-existent current working directory. The steps to reproduce are: ``` mkdir test cd test rm -r ../test lazygit ``` (Note: I can repro this on Ubuntu, but not on macOS Sonoma, where lazygit starts regardless of whether the current working directory exists or not.) Here's how the repro steps look on Ubuntu with this PR applied: ``` simon@ubuntu:/Users/simon/src/3p/lazygit$ go build . simon@ubuntu:/Users/simon/src/3p/lazygit$ mkdir deleteme simon@ubuntu:/Users/simon/src/3p/lazygit$ cd deleteme/ simon@ubuntu:/Users/simon/src/3p/lazygit/deleteme$ rm -r ../deleteme simon@ubuntu:/Users/simon/src/3p/lazygit/deleteme$ ../lazygit 2024/01/02 18:40:15 Error: the current working directory does not exist ``` - **Please check if the PR fulfills these requirements** * [x] Cheatsheets are up-to-date (run `go generate ./...`) * [x] Code has been formatted (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#code-formatting)) * [x] Tests have been added/updated (see [here](https://github.com/jesseduffield/lazygit/blob/master/pkg/integration/README.md) for the integration test guide) * [x] Text is internationalised (see [here](https://github.com/jesseduffield/lazygit/blob/master/CONTRIBUTING.md#internationalisation)) * [x] Docs (specifically `docs/Config.md`) have been updated if necessary * [x] You've read through your own file changes for silly mistakes etc <!-- Be sure to name your PR with an imperative e.g. 'Add worktrees view' see https://github.com/jesseduffield/lazygit/releases/tag/v0.40.0 for examples -->
This commit is contained in:
commit
6e6fe6a489
@ -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 {
|
||||
|
@ -335,6 +335,7 @@ type TranslationSet struct {
|
||||
StashIncludeUntrackedChanges string
|
||||
StashOptions string
|
||||
NotARepository string
|
||||
WorkingDirectoryDoesNotExist string
|
||||
Jump string
|
||||
ScrollLeftRight string
|
||||
ScrollLeft string
|
||||
@ -1153,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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user