getInitDefaultBranch return init.defaultBranch value in git config. If init.defaultBranch isn't set, getInitDefaultBranch return 'main'.
()
| 157 | // getInitDefaultBranch return init.defaultBranch value in git config. |
| 158 | // If init.defaultBranch isn't set, getInitDefaultBranch return 'main'. |
| 159 | func getInitDefaultBranch() string { |
| 160 | cmd := exec.Command("git", "config", "--get", "init.defaultBranch") |
| 161 | |
| 162 | output, err := cmd.CombinedOutput() |
| 163 | |
| 164 | if err != nil { |
| 165 | return "main" |
| 166 | } |
| 167 | |
| 168 | branchName := strings.TrimSuffix(string(output), "\n") |
| 169 | return branchName |
| 170 | } |
| 171 | |
| 172 | // doInitialCommit runs the git commands that initialize and do the first commit to a repository. |
| 173 | func doInitialCommit(ownerName string, repositoryName string) error { |