Skip to content

Commit

Permalink
Don't exit app when GetRepoPaths call fails during startup (#3779)
Browse files Browse the repository at this point in the history
- **PR Description**
Fixes #3740 

As explained in the issue, 7a67096 moved some code around that caused a
call to `GetRepoPaths` to occur before `setupApp`, which usually handles
the scenario where we are not in a git directory. `GetRepoPaths` returns
an error if the path isn't a git repository, which caused the app to
exit before we reached `setupApp`.

When starting up lazygit, we ignore (and log) the error returned by
`GetRepoPaths`, and continue instead of exiting early. This allows us to
reach the step where we follow the user's `notARepository` config entry.
  • Loading branch information
stefanhaller authored Aug 3, 2024
2 parents 74fe069 + ef4fd70 commit a3560eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ func NewApp(config config.AppConfigurer, test integrationTypes.IntegrationTest,
return app, err
}

// If we're not in a repo, repoPaths will be nil. The error is moot for us
// If we're not in a repo, GetRepoPaths will return an error. The error is moot for us
// at this stage, since we'll try to init a new repo in setupRepo(), below
repoPaths, err := git_commands.GetRepoPaths(app.OSCommand.Cmd, gitVersion)
if err != nil {
return app, err
common.Log.Infof("Error getting repo paths: %v", err)
}

showRecentRepos, err := app.setupRepo(repoPaths)
Expand Down

0 comments on commit a3560eb

Please sign in to comment.