1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-05-29 23:17:32 +02:00

Add config option for notInRepo behaviour.

This commit is contained in:
Kalvin Pearce 2020-11-24 21:21:11 +10:00 committed by Jesse Duffield
parent 999e170f1d
commit d468866746
2 changed files with 16 additions and 4 deletions

View File

@ -192,10 +192,20 @@ func (app *App) setupRepo() (bool, error) {
return false, err // Current directory appears to be a git repository.
}
// Offer to initialize a new repository in current directory.
fmt.Print(app.Tr.CreateRepo)
response, _ := bufio.NewReader(os.Stdin).ReadString('\n')
if strings.Trim(response, " \n") != "y" {
shouldInitRepo := true
notARepository := app.Config.GetUserConfig().NotARepository
if(notARepository == "prompt") {
// Offer to initialize a new repository in current directory.
fmt.Print(app.Tr.CreateRepo)
response, _ := bufio.NewReader(os.Stdin).ReadString('\n')
if strings.Trim(response, " \n") != "y" {
shouldInitRepo = false
}
} else if(notARepository == "skip") {
shouldInitRepo = false
}
if !shouldInitRepo {
// check if we have a recent repo we can open
recentRepos := app.Config.GetAppState().RecentRepos
if len(recentRepos) > 0 {

View File

@ -14,6 +14,7 @@ type UserConfig struct {
DisableStartupPopups bool `yaml:"disableStartupPopups"`
CustomCommands []CustomCommand `yaml:"customCommands"`
Services map[string]string `yaml:"services"`
NotARepository string `yaml:"notARepository"`
}
type GuiConfig struct {
@ -442,5 +443,6 @@ func GetDefaultConfig() *UserConfig {
DisableStartupPopups: false,
CustomCommands: []CustomCommand(nil),
Services: map[string]string(nil),
NotARepository: "prompt",
}
}