]> source.dussan.org Git - gitea.git/commitdiff
Need a field to specify if repository is bare
authorUnknown <joe2010xtmf@163.com>
Sat, 22 Mar 2014 15:59:14 +0000 (11:59 -0400)
committerUnknown <joe2010xtmf@163.com>
Sat, 22 Mar 2014 15:59:14 +0000 (11:59 -0400)
models/action.go
models/repo.go
routers/repo/single.go

index 12122ae240fb7f41cfff0fb9ad24d8602dab3d5d..4e1107f891cd1b0196606b4bdd717dc4e6f10b21 100644 (file)
@@ -87,6 +87,7 @@ func CommitRepoAction(userId int64, userName string,
        if err != nil {
                return err
        }
+       repo.IsBare = false
        repo.Updated = time.Now()
        if err = UpdateRepository(repo); err != nil {
                return err
index 1961b31e949a1aa997d98e725663b8bb3574f6c3..fb115de59099de4793dc46f678f685a1e27eb907 100644 (file)
@@ -83,10 +83,11 @@ type Repository struct {
        Name        string `xorm:"index not null"`
        Description string
        Website     string
-       Private     bool
        NumWatches  int
        NumStars    int
        NumForks    int
+       IsPrivate   bool
+       IsBare      bool
        Created     time.Time `xorm:"created"`
        Updated     time.Time `xorm:"updated"`
 }
@@ -139,7 +140,8 @@ func CreateRepository(user *User, repoName, desc, repoLang, license string, priv
                Name:        repoName,
                LowerName:   strings.ToLower(repoName),
                Description: desc,
-               Private:     private,
+               IsPrivate:   private,
+               IsBare:      repoLang == "" && license == "" && !initReadme,
        }
 
        repoPath := RepoPath(user.Name, repoName)
index 37c0fabd7976da3a5007c4a945b99f090c80fe94..5906e64fb970816472a4ab346ec75e0011fbd576 100644 (file)
@@ -69,7 +69,7 @@ func Single(ctx *middleware.Context, params martini.Params) {
                log.Error("repo.Single(GetBranches): %v", err)
                ctx.Error(404)
                return
-       } else if len(brs) == 0 {
+       } else if ctx.Repo.Repository.IsBare {
                ctx.Data["IsBareRepo"] = true
                ctx.HTML(200, "repo/single")
                return
@@ -224,13 +224,7 @@ func Setting(ctx *middleware.Context, params martini.Params) {
 
        ctx.Data["IsRepoToolbarSetting"] = true
 
-       // Branches.
-       brs, err := models.GetBranches(params["username"], params["reponame"])
-       if err != nil {
-               log.Error("repo.Setting(GetBranches): %v", err)
-               ctx.Error(404)
-               return
-       } else if len(brs) == 0 {
+       if ctx.Repo.Repository.IsBare {
                ctx.Data["IsBareRepo"] = true
                ctx.HTML(200, "repo/setting")
                return