summaryrefslogtreecommitdiffstats
path: root/models
diff options
context:
space:
mode:
authorUnknown <joe2010xtmf@163.com>2014-05-01 12:03:10 -0400
committerUnknown <joe2010xtmf@163.com>2014-05-01 12:03:10 -0400
commit75109bbd653f69e4a924b6654e564341e4bcf229 (patch)
treefa3a334790fc5ed244ffa9fd0fff6ea8733a3a25 /models
parent0a187dbef5d2480f8d47b8013f6e21e06ea18cbd (diff)
downloadgitea-75109bbd653f69e4a924b6654e564341e4bcf229.tar.gz
gitea-75109bbd653f69e4a924b6654e564341e4bcf229.zip
Fix panic when no master branch
Diffstat (limited to 'models')
-rw-r--r--models/repo.go17
1 files changed, 10 insertions, 7 deletions
diff --git a/models/repo.go b/models/repo.go
index be889cba5f..35b3fde155 100644
--- a/models/repo.go
+++ b/models/repo.go
@@ -246,14 +246,17 @@ func CreateRepository(user *User, name, desc, lang, license string, private, mir
}
repo := &Repository{
- OwnerId: user.Id,
- Name: name,
- LowerName: strings.ToLower(name),
- Description: desc,
- IsPrivate: private,
- IsBare: lang == "" && license == "" && !initReadme,
- DefaultBranch: "master",
+ OwnerId: user.Id,
+ Name: name,
+ LowerName: strings.ToLower(name),
+ Description: desc,
+ IsPrivate: private,
+ IsBare: lang == "" && license == "" && !initReadme,
}
+ if !repo.IsBare {
+ repo.DefaultBranch = "master"
+ }
+
repoPath := RepoPath(user.Name, repo.Name)
sess := orm.NewSession()