chore: spacing
This commit is contained in:
parent
b1a0d54bd3
commit
a773fd4256
@ -15,9 +15,11 @@ func Init(repoPath string, commit bool, gitName, gitEmail string) error {
|
||||
if err != nil {
|
||||
return fmt.Errorf("git init: %s", err)
|
||||
}
|
||||
|
||||
if err = SwitchToMain(repo); err != nil {
|
||||
return fmt.Errorf("git branch rename: %s", err)
|
||||
}
|
||||
|
||||
log.Debugf("initialised new git repo in %s", repoPath)
|
||||
|
||||
if commit {
|
||||
@ -39,9 +41,11 @@ func Init(repoPath string, commit bool, gitName, gitEmail string) error {
|
||||
if gitName != "" && gitEmail != "" {
|
||||
author = &object.Signature{Name: gitName, Email: gitEmail}
|
||||
}
|
||||
|
||||
if _, err = commitWorktree.Commit("init", &git.CommitOptions{Author: author}); err != nil {
|
||||
return fmt.Errorf("git commit: %s", err)
|
||||
}
|
||||
|
||||
log.Debugf("init committed all files for new git repo in %s", repoPath)
|
||||
}
|
||||
|
||||
@ -54,14 +58,18 @@ func SwitchToMain(repo *git.Repository) error {
|
||||
if err := repo.Storer.SetReference(ref); err != nil {
|
||||
return fmt.Errorf("set reference: %s", err)
|
||||
}
|
||||
|
||||
cfg, err := repo.Config()
|
||||
if err != nil {
|
||||
return fmt.Errorf("repo config: %s", err)
|
||||
}
|
||||
|
||||
cfg.Init.DefaultBranch = "main"
|
||||
if err := repo.SetConfig(cfg); err != nil {
|
||||
return fmt.Errorf("repo set config: %s", err)
|
||||
}
|
||||
log.Debug("set 'main' as the default branch.")
|
||||
|
||||
log.Debug("set 'main' as the default branch")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user