1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-12-04 10:34:55 +02:00

Ask for initial branch name

This commit is contained in:
Luka Markušić 2022-06-30 13:53:58 +02:00
parent 41071c3703
commit f1efa02640
2 changed files with 11 additions and 1 deletions

View File

@ -173,12 +173,20 @@ func (app *App) setupRepo() (bool, error) {
shouldInitRepo := true
notARepository := app.UserConfig.NotARepository
initialBranch := ""
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, " \r\n") != "y" {
shouldInitRepo = false
} else {
// Ask for the initial branch name
fmt.Print(app.Tr.InitialBranch)
response, _ := bufio.NewReader(os.Stdin).ReadString('\n')
if trimmedResponse := strings.Trim(response, " \r\n"); len(trimmedResponse) > 0 {
initialBranch += "--initial-branch=" + trimmedResponse
}
}
} else if notARepository == "skip" {
shouldInitRepo = false
@ -197,7 +205,7 @@ func (app *App) setupRepo() (bool, error) {
fmt.Println(app.Tr.NoRecentRepositories)
os.Exit(1)
}
if err := app.OSCommand.Cmd.New("git init").Run(); err != nil {
if err := app.OSCommand.Cmd.New("git init " + initialBranch).Run(); err != nil {
return false, err
}
}

View File

@ -258,6 +258,7 @@ type TranslationSet struct {
DiscardFileChangesPrompt string
DisabledForGPG string
CreateRepo string
InitialBranch string
NoRecentRepositories string
AutoStashTitle string
AutoStashPrompt string
@ -884,6 +885,7 @@ func EnglishTranslationSet() TranslationSet {
DiscardFileChangesPrompt: "Are you sure you want to discard this commit's changes to this file? If this file was created in this commit, it will be deleted",
DisabledForGPG: "Feature not available for users using GPG",
CreateRepo: "Not in a git repository. Create a new git repository? (y/n): ",
InitialBranch: "Branch name? (leave empty for git's default): ",
NoRecentRepositories: "Must open lazygit in a git repository. No valid recent repositories. Exiting.",
AutoStashTitle: "Autostash?",
AutoStashPrompt: "You must stash and pop your changes to bring them across. Do this automatically? (enter/esc)",