Skip to content

Commit e3f55ca

Browse files
committed
Need a field to specify if repository is bare
1 parent cd070b5 commit e3f55ca

File tree

3 files changed

+7
-10
lines changed

3 files changed

+7
-10
lines changed

models/action.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func CommitRepoAction(userId int64, userName string,
8787
if err != nil {
8888
return err
8989
}
90+
repo.IsBare = false
9091
repo.Updated = time.Now()
9192
if err = UpdateRepository(repo); err != nil {
9293
return err

models/repo.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,10 +83,11 @@ type Repository struct {
8383
Name string `xorm:"index not null"`
8484
Description string
8585
Website string
86-
Private bool
8786
NumWatches int
8887
NumStars int
8988
NumForks int
89+
IsPrivate bool
90+
IsBare bool
9091
Created time.Time `xorm:"created"`
9192
Updated time.Time `xorm:"updated"`
9293
}
@@ -139,7 +140,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
139140
Name: repoName,
140141
LowerName: strings.ToLower(repoName),
141142
Description: desc,
142-
Private: private,
143+
IsPrivate: private,
144+
IsBare: repoLang == "" && license == "" && !initReadme,
143145
}
144146

145147
repoPath := RepoPath(user.Name, repoName)

routers/repo/single.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
6969
log.Error("repo.Single(GetBranches): %v", err)
7070
ctx.Error(404)
7171
return
72-
} else if len(brs) == 0 {
72+
} else if ctx.Repo.Repository.IsBare {
7373
ctx.Data["IsBareRepo"] = true
7474
ctx.HTML(200, "repo/single")
7575
return
@@ -224,13 +224,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
224224

225225
ctx.Data["IsRepoToolbarSetting"] = true
226226

227-
// Branches.
228-
brs, err := models.GetBranches(params["username"], params["reponame"])
229-
if err != nil {
230-
log.Error("repo.Setting(GetBranches): %v", err)
231-
ctx.Error(404)
232-
return
233-
} else if len(brs) == 0 {
227+
if ctx.Repo.Repository.IsBare {
234228
ctx.Data["IsBareRepo"] = true
235229
ctx.HTML(200, "repo/setting")
236230
return

0 commit comments

Comments
 (0)