1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-06-04 23:37:41 +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. return false, err // Current directory appears to be a git repository.
} }
// Offer to initialize a new repository in current directory. shouldInitRepo := true
fmt.Print(app.Tr.CreateRepo) notARepository := app.Config.GetUserConfig().NotARepository
response, _ := bufio.NewReader(os.Stdin).ReadString('\n') if(notARepository == "prompt") {
if strings.Trim(response, " \n") != "y" { // 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 // check if we have a recent repo we can open
recentRepos := app.Config.GetAppState().RecentRepos recentRepos := app.Config.GetAppState().RecentRepos
if len(recentRepos) > 0 { if len(recentRepos) > 0 {

View File

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