|
@@ -223,7 +223,7 @@ func (repo *Repository) AfterSet(colName string, _ xorm.Cell) {
|
|
|
case "default_branch":
|
|
|
// FIXME: use db migration to solve all at once.
|
|
|
if repo.DefaultBranch == "" {
|
|
|
- repo.DefaultBranch = "master"
|
|
|
+ repo.DefaultBranch = conf.Repository.DefaultBranch
|
|
|
}
|
|
|
case "num_closed_issues":
|
|
|
repo.NumOpenIssues = repo.NumIssues - repo.NumClosedIssues
|
|
@@ -975,10 +975,9 @@ func getRepoInitFile(tp, name string) ([]byte, error) {
|
|
|
|
|
|
func prepareRepoCommit(repo *Repository, tmpDir, repoPath string, opts CreateRepoOptionsLegacy) error {
|
|
|
// Clone to temporary path and do the init commit.
|
|
|
- _, stderr, err := process.Exec(
|
|
|
- fmt.Sprintf("initRepository(git clone): %s", repoPath), "git", "clone", repoPath, tmpDir)
|
|
|
+ err := git.Clone(repoPath, tmpDir, git.CloneOptions{})
|
|
|
if err != nil {
|
|
|
- return fmt.Errorf("git clone: %v - %s", err, stderr)
|
|
|
+ return errors.Wrap(err, "clone")
|
|
|
}
|
|
|
|
|
|
// README
|
|
@@ -1049,6 +1048,18 @@ func initRepository(e Engine, repoPath string, doer *User, repo *Repository, opt
|
|
|
return fmt.Errorf("createDelegateHooks: %v", err)
|
|
|
}
|
|
|
|
|
|
+ // Set default branch
|
|
|
+ _, err = git.SymbolicRef(
|
|
|
+ repoPath,
|
|
|
+ git.SymbolicRefOptions{
|
|
|
+ Name: "HEAD",
|
|
|
+ Ref: git.RefsHeads + conf.Repository.DefaultBranch,
|
|
|
+ },
|
|
|
+ )
|
|
|
+ if err != nil {
|
|
|
+ return errors.Wrap(err, "set default branch")
|
|
|
+ }
|
|
|
+
|
|
|
tmpDir := filepath.Join(os.TempDir(), "gogs-"+repo.Name+"-"+com.ToStr(time.Now().Nanosecond()))
|
|
|
|
|
|
// Initialize repository according to user's choice.
|
|
@@ -1086,7 +1097,7 @@ func initRepository(e Engine, repoPath string, doer *User, repo *Repository, opt
|
|
|
repo.IsBare = true
|
|
|
}
|
|
|
|
|
|
- repo.DefaultBranch = "master"
|
|
|
+ repo.DefaultBranch = conf.Repository.DefaultBranch
|
|
|
if err = updateRepository(e, repo, false); err != nil {
|
|
|
return fmt.Errorf("updateRepository: %v", err)
|
|
|
}
|