]> source.dussan.org Git - gitea.git/commitdiff
Refactor repo.isBare to repo.isEmpty #5629 (#5714)
authorzeripath <art27@cantab.net>
Fri, 18 Jan 2019 00:01:04 +0000 (00:01 +0000)
committertechknowlogick <hello@techknowlogick.com>
Fri, 18 Jan 2019 00:01:04 +0000 (19:01 -0500)
* Refactor repo.isBare to repo.isEmpty #5629

Signed-off-by: Andrew Thornton <art27@cantab.net>
* Remove Sync call

41 files changed:
integrations/bare_repo_test.go [deleted file]
integrations/empty_repo_test.go [new file with mode: 0644]
models/action.go
models/fixtures/repository.yml
models/migrations/migrations.go
models/migrations/v78.go [new file with mode: 0644]
models/repo.go
modules/context/api.go
modules/context/repo.go
options/locale/locale_cs-CZ.ini
options/locale/locale_de-DE.ini
options/locale/locale_en-US.ini
options/locale/locale_es-ES.ini
options/locale/locale_fr-FR.ini
options/locale/locale_hu-HU.ini
options/locale/locale_id-ID.ini
options/locale/locale_it-IT.ini
options/locale/locale_ja-JP.ini
options/locale/locale_ko-KR.ini
options/locale/locale_lv-LV.ini
options/locale/locale_nl-NL.ini
options/locale/locale_pl-PL.ini
options/locale/locale_pt-BR.ini
options/locale/locale_ru-RU.ini
options/locale/locale_sv-SE.ini
options/locale/locale_tr-TR.ini
options/locale/locale_uk-UA.ini
options/locale/locale_zh-CN.ini
options/locale/locale_zh-HK.ini
options/locale/locale_zh-TW.ini
routers/api/v1/repo/file.go
routers/repo/pull.go
routers/repo/repo.go
routers/repo/view.go
routers/routes/routes.go
templates/repo/bare.tmpl [deleted file]
templates/repo/empty.tmpl [new file with mode: 0644]
templates/repo/header.tmpl
templates/repo/settings/branches.tmpl
templates/repo/settings/navbar.tmpl
templates/repo/sub_menu.tmpl

diff --git a/integrations/bare_repo_test.go b/integrations/bare_repo_test.go
deleted file mode 100644 (file)
index e693c18..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2017 The Gitea Authors. All rights reserved.
-// Use of this source code is governed by a MIT-style
-// license that can be found in the LICENSE file.
-
-package integrations
-
-import (
-       "net/http"
-       "testing"
-
-       "code.gitea.io/gitea/models"
-)
-
-func TestBareRepo(t *testing.T) {
-       prepareTestEnv(t)
-       subpaths := []string{
-               "commits/master",
-               "raw/foo",
-               "commit/1ae57b34ccf7e18373",
-               "graph",
-       }
-       bareRepo := models.AssertExistsAndLoadBean(t, &models.Repository{}, models.Cond("is_bare = ?", true)).(*models.Repository)
-       owner := models.AssertExistsAndLoadBean(t, &models.User{ID: bareRepo.OwnerID}).(*models.User)
-       for _, subpath := range subpaths {
-               req := NewRequestf(t, "GET", "/%s/%s/%s", owner.Name, bareRepo.Name, subpath)
-               MakeRequest(t, req, http.StatusNotFound)
-       }
-}
diff --git a/integrations/empty_repo_test.go b/integrations/empty_repo_test.go
new file mode 100644 (file)
index 0000000..2d72546
--- /dev/null
@@ -0,0 +1,28 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package integrations
+
+import (
+       "net/http"
+       "testing"
+
+       "code.gitea.io/gitea/models"
+)
+
+func TestEmptyRepo(t *testing.T) {
+       prepareTestEnv(t)
+       subpaths := []string{
+               "commits/master",
+               "raw/foo",
+               "commit/1ae57b34ccf7e18373",
+               "graph",
+       }
+       emptyRepo := models.AssertExistsAndLoadBean(t, &models.Repository{}, models.Cond("is_empty = ?", true)).(*models.Repository)
+       owner := models.AssertExistsAndLoadBean(t, &models.User{ID: emptyRepo.OwnerID}).(*models.User)
+       for _, subpath := range subpaths {
+               req := NewRequestf(t, "GET", "/%s/%s/%s", owner.Name, emptyRepo.Name, subpath)
+               MakeRequest(t, req, http.StatusNotFound)
+       }
+}
index d917c3774614f43ef3f34b9b8afc99e747c5c5dd..5dc0eb18e699e4b3767954467a4ceb0e62480ca3 100644 (file)
@@ -574,13 +574,13 @@ func CommitRepoAction(opts CommitRepoActionOptions) error {
 
        refName := git.RefEndName(opts.RefFullName)
 
-       // Change default branch and bare status only if pushed ref is non-empty branch.
-       if repo.IsBare && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
+       // Change default branch and empty status only if pushed ref is non-empty branch.
+       if repo.IsEmpty && opts.NewCommitID != git.EmptySHA && strings.HasPrefix(opts.RefFullName, git.BranchPrefix) {
                repo.DefaultBranch = refName
-               repo.IsBare = false
+               repo.IsEmpty = false
        }
 
-       // Change repository bare status and update last updated time.
+       // Change repository empty status and update last updated time.
        if err = UpdateRepository(repo, false); err != nil {
                return fmt.Errorf("UpdateRepository: %v", err)
        }
index aa96656530aec3ae3ed7fd3c931ac58185006cd6..d412e52d8e56c10e7c22fb5bd1b597337c53d811 100644 (file)
   owner_id: 2
   lower_name: repo15
   name: repo15
-  is_bare: true
+  is_empty: true
 
 -
   id: 16
index 4c6b6d64bcc2265d6aa404237e9eac03860aea85..533ff90738e773b065141b77ae56c7ca1c1b774a 100644 (file)
@@ -208,6 +208,8 @@ var migrations = []Migration{
        NewMigration("add pull request rebase with merge commit", addPullRequestRebaseWithMerge),
        // v77 -> v78
        NewMigration("add theme to users", addUserDefaultTheme),
+       // v78 -> v79
+       NewMigration("rename repo is_bare to repo is_empty", renameRepoIsBareToIsEmpty),
 }
 
 // Migrate database to current version
diff --git a/models/migrations/v78.go b/models/migrations/v78.go
new file mode 100644 (file)
index 0000000..d2b637d
--- /dev/null
@@ -0,0 +1,42 @@
+// Copyright 2019 The Gitea Authors. All rights reserved.
+// Use of this source code is governed by a MIT-style
+// license that can be found in the LICENSE file.
+
+package migrations
+
+import (
+       "fmt"
+       "strings"
+
+       "code.gitea.io/gitea/models"
+
+       "github.com/go-xorm/xorm"
+)
+
+func renameRepoIsBareToIsEmpty(x *xorm.Engine) error {
+       type Repository struct {
+               ID      int64 `xorm:"pk autoincr"`
+               IsBare  bool
+               IsEmpty bool `xorm:"INDEX"`
+       }
+
+       sess := x.NewSession()
+       defer sess.Close()
+       if err := sess.Begin(); err != nil {
+               return err
+       }
+       var err error
+       if models.DbCfg.Type == "mssql" {
+               _, err = sess.Query("EXEC sp_rename 'repository.is_bare', 'is_empty', 'COLUMN'")
+       } else {
+               _, err = sess.Query("ALTER TABLE \"repository\" RENAME COLUMN \"is_bare\" TO \"is_empty\";")
+       }
+       if err != nil {
+               if strings.Contains(err.Error(), "no such column") {
+                       return nil
+               }
+               return fmt.Errorf("select repositories: %v", err)
+       }
+
+       return sess.Commit()
+}
index 86d3e44a1fb590d6b97381dcf0f121f432508e8f..d2b163ff65006d3cfed3f0c0941a0f200177b7c7 100644 (file)
@@ -187,7 +187,7 @@ type Repository struct {
        NumReleases         int `xorm:"-"`
 
        IsPrivate bool `xorm:"INDEX"`
-       IsBare    bool `xorm:"INDEX"`
+       IsEmpty   bool `xorm:"INDEX"`
 
        IsMirror bool `xorm:"INDEX"`
        *Mirror  `xorm:"-"`
@@ -291,7 +291,7 @@ func (repo *Repository) innerAPIFormat(e Engine, mode AccessMode, isParent bool)
                FullName:      repo.FullName(),
                Description:   repo.Description,
                Private:       repo.IsPrivate,
-               Empty:         repo.IsBare,
+               Empty:         repo.IsEmpty,
                Size:          int(repo.Size / 1024),
                Fork:          repo.IsFork,
                Parent:        parent,
@@ -656,7 +656,7 @@ func (repo *Repository) CanUserFork(user *User) (bool, error) {
 
 // CanEnablePulls returns true if repository meets the requirements of accepting pulls.
 func (repo *Repository) CanEnablePulls() bool {
-       return !repo.IsMirror && !repo.IsBare
+       return !repo.IsMirror && !repo.IsEmpty
 }
 
 // AllowsPulls returns true if repository meets the requirements of accepting pulls and has them enabled.
@@ -954,13 +954,13 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err
        _, stderr, err := com.ExecCmdDir(repoPath, "git", "log", "-1")
        if err != nil {
                if strings.Contains(stderr, "fatal: bad default revision 'HEAD'") {
-                       repo.IsBare = true
+                       repo.IsEmpty = true
                } else {
-                       return repo, fmt.Errorf("check bare: %v - %s", err, stderr)
+                       return repo, fmt.Errorf("check empty: %v - %s", err, stderr)
                }
        }
 
-       if !repo.IsBare {
+       if !repo.IsEmpty {
                // Try to get HEAD branch and set it as default branch.
                gitRepo, err := git.OpenRepository(repoPath)
                if err != nil {
@@ -999,7 +999,7 @@ func MigrateRepository(doer, u *User, opts MigrateRepoOptions) (*Repository, err
                repo, err = CleanUpMigrateInfo(repo)
        }
 
-       if err != nil && !repo.IsBare {
+       if err != nil && !repo.IsEmpty {
                UpdateRepoIndexer(repo)
        }
 
@@ -1214,7 +1214,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C
                return fmt.Errorf("initRepository: path already exists: %s", repoPath)
        }
 
-       // Init bare new repository.
+       // Init git bare new repository.
        if err = git.InitRepository(repoPath, true); err != nil {
                return fmt.Errorf("InitRepository: %v", err)
        } else if err = createDelegateHooks(repoPath); err != nil {
@@ -1249,7 +1249,7 @@ func initRepository(e Engine, repoPath string, u *User, repo *Repository, opts C
        }
 
        if !opts.AutoInit {
-               repo.IsBare = true
+               repo.IsEmpty = true
        }
 
        repo.DefaultBranch = "master"
index 6a9c792370f4fd23c08c84bbcd0f7d72c573e355..b27ffcbc8cc57a8eff3a61c673a541739413b7a8 100644 (file)
@@ -124,7 +124,7 @@ func APIContexter() macaron.Handler {
 func ReferencesGitRepo() macaron.Handler {
        return func(ctx *APIContext) {
                // Empty repository does not have reference information.
-               if ctx.Repo.Repository.IsBare {
+               if ctx.Repo.Repository.IsEmpty {
                        return
                }
 
index 55d607a28ac4d8a28e5c27e030d58289f16015fc..c10abdcb7b1a8e21d35e29caee4277161d42196a 100644 (file)
@@ -234,7 +234,7 @@ func repoAssignment(ctx *Context, repo *models.Repository) {
 
        ctx.Repo.Repository = repo
        ctx.Data["RepoName"] = ctx.Repo.Repository.Name
-       ctx.Data["IsBareRepo"] = ctx.Repo.Repository.IsBare
+       ctx.Data["IsEmptyRepo"] = ctx.Repo.Repository.IsEmpty
 }
 
 // RepoIDAssignment returns a macaron handler which assigns the repo to the context.
@@ -370,8 +370,8 @@ func RepoAssignment() macaron.Handler {
                        ctx.Data["IsStaringRepo"] = models.IsStaring(ctx.User.ID, repo.ID)
                }
 
-               // repo is bare and display enable
-               if ctx.Repo.Repository.IsBare {
+               // repo is empty and display enable
+               if ctx.Repo.Repository.IsEmpty {
                        ctx.Data["BranchName"] = ctx.Repo.Repository.DefaultBranch
                        return
                }
@@ -520,7 +520,7 @@ func getRefName(ctx *Context, pathType RepoRefType) string {
 func RepoRefByType(refType RepoRefType) macaron.Handler {
        return func(ctx *Context) {
                // Empty repository does not have reference information.
-               if ctx.Repo.Repository.IsBare {
+               if ctx.Repo.Repository.IsEmpty {
                        return
                }
 
@@ -549,7 +549,7 @@ func RepoRefByType(refType RepoRefType) macaron.Handler {
                                        ctx.ServerError("GetBranches", err)
                                        return
                                } else if len(brs) == 0 {
-                                       err = fmt.Errorf("No branches in non-bare repository %s",
+                                       err = fmt.Errorf("No branches in non-empty repository %s",
                                                ctx.Repo.GitRepo.Path)
                                        ctx.ServerError("GetBranches", err)
                                        return
index f7318ffd6cc28e2834da97113e5a28f0d39e0533..c5c632d57bca1292b0a90490ede15829171ea5d3 100644 (file)
@@ -578,7 +578,7 @@ quick_guide=Krátká příručka
 clone_this_repo=Naklonovat tento repozitář
 create_new_repo_command=Vytvořit nový repozitář na příkazové řádce
 push_exist_repo=Nahrání existujícího repozitáře z příkazové řádky
-bare_message=Tento repozitář nemá žádný obsah.
+empty_message=Tento repozitář nemá žádný obsah.
 
 code=Zdrojový kód
 code.desc=Přístup ke zdrojovým kódům, souborům, revizím a větvím.
index a73fc55c251cf2fbc99bab583d5578fbce335ba7..f74cfa32013344b3c601e91d72cbd8fb4e560b57 100644 (file)
@@ -572,7 +572,7 @@ quick_guide=Kurzanleitung
 clone_this_repo=Dieses Repository klonen
 create_new_repo_command=Erstelle ein neues Repository von der Kommandozeile aus
 push_exist_repo=Bestehendes Repository via Kommandozeile pushen
-bare_message=Dieses Repository hat noch keinen Inhalt.
+empty_message=Dieses Repository hat noch keinen Inhalt.
 
 code=Code
 code.desc=Zugriff auf Quellcode, Dateien, Commits und Branches.
index fd51ca678e192a3f4eedf408e25c38e59c886af0..151629ea6d0bdb597f46e2707ec12f8b4e70d76e 100644 (file)
@@ -578,7 +578,7 @@ quick_guide = Quick Guide
 clone_this_repo = Clone this repository
 create_new_repo_command = Creating a new repository on the command line
 push_exist_repo = Pushing an existing repository from the command line
-bare_message = This repository does not contain any content.
+empty_message = This repository does not contain any content.
 
 code = Code
 code.desc = Access source code, files, commits and branches.
index c646ced17ce93b5aec2d5f4ff901c6f794c78682..47a0ffd6d338f71839c1bb3a74c255c697470b6a 100644 (file)
@@ -356,7 +356,7 @@ quick_guide=Guía rápida
 clone_this_repo=Clonar este repositorio
 create_new_repo_command=Crear un nuevo repositorio desde línea de comandos
 push_exist_repo=Hacer push de un repositorio existente desde línea de comandos
-bare_message=Este repositorio no contiene ningún contenido.
+empty_message=Este repositorio no contiene ningún contenido.
 
 code=Código
 branch=Rama
index f8faaec54dd42dc0f3252cf5a805fda1f6962af4..3c7443bfc828b75eff8c672bd5077bc9ba3bfb63 100644 (file)
@@ -578,7 +578,7 @@ quick_guide=Introduction rapide
 clone_this_repo=Cloner ce dépôt
 create_new_repo_command=Création d'un nouveau dépôt en ligne de commande
 push_exist_repo=Soumission d'un dépôt existant par ligne de commande
-bare_message=Ce dépôt ne contient aucune information.
+empty_message=Ce dépôt ne contient aucune information.
 
 code=Code
 code.desc=Accéder au code source, fichiers, révisions et branches.
index cd7874207b29b2faa0bd68efe60e618836b413a6..7c73e4053f75a9a8a8a9e9e973c8ff521a28ba92 100644 (file)
@@ -289,7 +289,7 @@ quick_guide=Gyors útmutató
 clone_this_repo=Tároló klónozása
 create_new_repo_command=Egy új tároló létrehozása a parancssorból
 push_exist_repo=Meglévő tároló feltöltése parancssorból
-bare_message=A tároló nem tartalmaz semmit, üres.
+empty_message=A tároló nem tartalmaz semmit, üres.
 
 code=Kód
 branch=Ág
index c5b9a2d7c603ecfdfa6337fcd40e8c4bd8fd5df3..d34fa5d031ea216e83ecffb01c781d98291eac4f 100644 (file)
@@ -358,7 +358,7 @@ quick_guide=Panduan Cepat
 clone_this_repo=Klon repositori ini
 create_new_repo_command=Membuat repositori baru pada baris perintah
 push_exist_repo=Mendorong sebuah repositori yang ada di baris perintah
-bare_message=Repositori ini tidak berisi konten apapun.
+empty_message=Repositori ini tidak berisi konten apapun.
 
 code=Kode
 branch=Cabang
index 6bbefcc90e8bba6171c86c4baad6e99cd9c3d754..ba3bc1b524fd15301368d8a7c17577027857d551 100644 (file)
@@ -534,7 +534,7 @@ quick_guide=Guida rapida
 clone_this_repo=Clona questo repository
 create_new_repo_command=Creazione di un nuovo repository da riga di comando
 push_exist_repo=Push di un repository esistente da riga di comando
-bare_message=Questo repository non contiene alcun contenuto.
+empty_message=Questo repository non contiene alcun contenuto.
 
 code=Codice
 code.desc=Accedi al codice sorgente, file, commits e branches.
index ea5178fa252abac5940781b28145c8deba9e0efa..f768ef9e92f5b7cc8db35490a3a5954ee90639ef 100644 (file)
@@ -578,7 +578,7 @@ quick_guide=クイック ガイド
 clone_this_repo=このリポジトリのクローンを作成
 create_new_repo_command=コマンドラインから新しいリポジトリを作成
 push_exist_repo=コマンドラインから既存のリポジトリをプッシュ
-bare_message=このリポジトリには内容がありません。
+empty_message=このリポジトリには内容がありません。
 
 code=コード
 code.desc=ソースコード、ファイル、コミット、ブランチにアクセス。
index d9660e9911567fe5f94825a1699320968117aaed..6c876da2d127a9f8237314e20af9ee0914a60310 100644 (file)
@@ -270,7 +270,7 @@ quick_guide=퀵 가이드
 clone_this_repo=이 저장소 복제
 create_new_repo_command=커맨드 라인에서 새 레포리지터리 생성
 push_exist_repo=커맨드라인에서 기존 레포지터리 푸시
-bare_message=이 레포지터리에는 아무것도 없습니다.
+empty_message=이 레포지터리에는 아무것도 없습니다.
 
 code=코드
 branch=브렌치
index dea7d532711ec64548dc82f58b0e429bac1bff9b..316ba001e79e0b699387ceead205ba631ca2e989 100644 (file)
@@ -571,7 +571,7 @@ quick_guide=Īsa pamācība
 clone_this_repo=Klonēt šo repozitoriju
 create_new_repo_command=Izveidot jaunu repozitoriju komandrindā
 push_exist_repo=Nosūtīt izmaiņas no komandrindas eksistējošam repozitorijam
-bare_message=Repozitorijs ir tukšs.
+empty_message=Repozitorijs ir tukšs.
 
 code=Kods
 code.desc=Piekļūt pirmkodam, failiem, revīzijām un atzariem.
index 401a7eaa68829bc7eeeb64d77f47574034d2e4c3..b06faf56888c84be571f11865eef1c73071d7bd1 100644 (file)
@@ -470,7 +470,7 @@ quick_guide=Snelstart gids
 clone_this_repo=Kloon deze repository
 create_new_repo_command=Maak een nieuwe repository aan vanaf de console
 push_exist_repo=Push een bestaande repositorie vanaf de console
-bare_message=Deze repository bevat geen inhoud.
+empty_message=Deze repository bevat geen inhoud.
 
 code=Code
 branch=Branch
index 34700568309a4a81c171590f645e248d947f921b..3ad43f73e877efd033909eb7788d2b67d9edc921 100644 (file)
@@ -554,7 +554,7 @@ quick_guide=Skrócona instrukcja
 clone_this_repo=Klonuj repozytorium
 create_new_repo_command=Tworzenie nowego repozytorium z linii poleceń
 push_exist_repo=Wypychanie istniejącego repozytorium z linii poleceń
-bare_message=Repozytorium jest puste.
+empty_message=Repozytorium jest puste.
 
 code=Kod
 branch=Gałąź
index 88a66b997e964bc6e89c53388fe9d1b050195d84..2e2cead09071fc69410752f6db8a416a1e960017 100644 (file)
@@ -578,7 +578,7 @@ quick_guide=Guia Rápido
 clone_this_repo=Clonar este repositório
 create_new_repo_command=Criando um novo repositório por linha de comando
 push_exist_repo=Realizando push para um repositório existente por linha de comando
-bare_message=Este repositório está vazio.
+empty_message=Este repositório está vazio.
 
 code=Código
 code.desc=Acesso a código-fonte, arquivos, commits e branches.
index e6a80586cc1361b0f76be4a966bca1e255e5583c..c410a5eaf85306d0cb25994030e83aa8f1af3c84 100644 (file)
@@ -562,7 +562,7 @@ quick_guide=Краткое руководство
 clone_this_repo=Клонировать репозиторий
 create_new_repo_command=Создать новый репозиторий из командной строки
 push_exist_repo=Push существующего репозитория из командной строки
-bare_message=В репозитории нет файлов.
+empty_message=В репозитории нет файлов.
 
 code=Код
 code.desc=Исходный код, файлы, коммиты и ветки.
index 7cd838810945a42f64da1326b75a1a396f411d86..b1d1973e11eb7bf71377fd0248465a2b7bc3c5dd 100644 (file)
@@ -551,7 +551,7 @@ quick_guide=Snabbguide
 clone_this_repo=Klona detta repo
 create_new_repo_command=Skapa en ny utvecklingskatalog på kommandoraden
 push_exist_repo=Pusha en existerande utvecklingskatalog från kommandoraden
-bare_message=Denna utvecklingskatalog är tom.
+empty_message=Denna utvecklingskatalog är tom.
 
 code=Kod
 code.desc=Se källkod, filer, commits och brancher.
index be0e176aa1987542955a1f4c2c8a4108ba8a2c91..7b2c8d7b9c7cd9a79525309875d239ceafb56b21 100644 (file)
@@ -283,7 +283,7 @@ quick_guide=Hızlı Başlangıç Kılavuzu
 clone_this_repo=Bu depoyu klonla
 create_new_repo_command=Komut satırında yeni bir depo oluşturuluyor
 push_exist_repo=Komut satırından mevcut bir depo itiliyor
-bare_message=Bu depo herhangi bir içerik içermiyor.
+empty_message=Bu depo herhangi bir içerik içermiyor.
 
 code=Kod
 branch=Dal
index 8f83021ffebd5e5f66bc96e8e4da081005e1e83f..8053c858fb8bc21fe8bc636a850a5d07d9141ecc 100644 (file)
@@ -562,7 +562,7 @@ quick_guide=Короткий посібник
 clone_this_repo=Кнонувати цей репозиторій
 create_new_repo_command=Створити новий репозиторій з командного рядка
 push_exist_repo=Опублікувати існуючий репозиторій з командного рядка
-bare_message=Цей репозиторій порожній.
+empty_message=Цей репозиторій порожній.
 
 code=Код
 code.desc=Доступ до коду, файлів, комітів та гілок.
index 8fe6695c81b9e8dd5706d9718c9713744e5ac178..9dda43727abb49f8c85111aaff06cf97d464626a 100644 (file)
@@ -577,7 +577,7 @@ quick_guide=快速帮助
 clone_this_repo=克隆当前仓库
 create_new_repo_command=从命令行创建一个新的仓库
 push_exist_repo=从命令行推送已经创建的仓库
-bare_message=这个家伙很懒,什么都没有推送。
+empty_message=这个家伙很懒,什么都没有推送。
 
 code=代码
 code.desc=查看源码、文件、提交和分支。
index 759c831307364ce81d8c12d87de8e460d5c3d72a..7aa63e1585960ad8be5934dcf3986b377e9d8d03 100644 (file)
@@ -275,7 +275,7 @@ quick_guide=快速幫助
 clone_this_repo=複製當前儲存庫
 create_new_repo_command=從命令列建立新儲存庫。
 push_exist_repo=從命令列推送已存在的儲存庫
-bare_message=此儲存庫未包含任何內容。
+empty_message=此儲存庫未包含任何內容。
 
 code=程式碼
 branch=分支
index 8568dbe9d826d7716a4140fba771e4871d72f149..e6408b86f59e1247009ec6d863c03e0a1993aa87 100644 (file)
@@ -500,7 +500,7 @@ quick_guide=快速幫助
 clone_this_repo=複製此儲存庫
 create_new_repo_command=從命令列建立新儲存庫。
 push_exist_repo=從命令行推送已經建立的儲存庫
-bare_message=此儲存庫未包含任何內容。
+empty_message=此儲存庫未包含任何內容。
 
 code=程式碼
 branch=分支
index 81f2332089d95b0cfd0a197882fd4c410a0575f4..762a0f25d99eaecaa9e1e3e1532fd7d5d4fdc4e0 100644 (file)
@@ -39,7 +39,7 @@ func GetRawFile(ctx *context.APIContext) {
        // responses:
        //   200:
        //     description: success
-       if ctx.Repo.Repository.IsBare {
+       if ctx.Repo.Repository.IsEmpty {
                ctx.Status(404)
                return
        }
index 36135084aaab030b496019c8876718fa579860c5..688a033fdbf192b8b207068211fc8773549e3fd0 100644 (file)
@@ -63,7 +63,7 @@ func getForkRepository(ctx *context.Context) *models.Repository {
                return nil
        }
 
-       if forkRepo.IsBare || !perm.CanRead(models.UnitTypeCode) {
+       if forkRepo.IsEmpty || !perm.CanRead(models.UnitTypeCode) {
                ctx.NotFound("getForkRepository", nil)
                return nil
        }
index 6071b7a54a8706964ca4994c3f7d8ad5878bbd71..960961a5e569c197f9f1fbde36cd9445531d4f00 100644 (file)
@@ -28,10 +28,10 @@ const (
        tplMigrate base.TplName = "repo/migrate"
 )
 
-// MustBeNotBare render when a repo is a bare git dir
-func MustBeNotBare(ctx *context.Context) {
-       if ctx.Repo.Repository.IsBare {
-               ctx.NotFound("MustBeNotBare", nil)
+// MustBeNotEmpty render when a repo is a empty git dir
+func MustBeNotEmpty(ctx *context.Context) {
+       if ctx.Repo.Repository.IsEmpty {
+               ctx.NotFound("MustBeNotEmpty", nil)
        }
 }
 
index 8739c139d975c3d65c5bce02ea56a43c915f2bc1..66977e3b5e828de1552e73c72e00f274390f53d1 100644 (file)
@@ -30,10 +30,10 @@ import (
 )
 
 const (
-       tplRepoBARE base.TplName = "repo/bare"
-       tplRepoHome base.TplName = "repo/home"
-       tplWatchers base.TplName = "repo/watchers"
-       tplForks    base.TplName = "repo/forks"
+       tplRepoEMPTY base.TplName = "repo/empty"
+       tplRepoHome  base.TplName = "repo/home"
+       tplWatchers  base.TplName = "repo/watchers"
+       tplForks     base.TplName = "repo/forks"
 )
 
 func renderDirectory(ctx *context.Context, treeLink string) {
@@ -321,8 +321,8 @@ func Home(ctx *context.Context) {
 func renderCode(ctx *context.Context) {
        ctx.Data["PageIsViewCode"] = true
 
-       if ctx.Repo.Repository.IsBare {
-               ctx.HTML(200, tplRepoBARE)
+       if ctx.Repo.Repository.IsEmpty {
+               ctx.HTML(200, tplRepoEMPTY)
                return
        }
 
index 6011427321aed3d378b4298b98f8b57cf1b75c31..afbb31d780281972dc6c11696bb9397e4943eb62 100644 (file)
@@ -478,7 +478,7 @@ func RegisterRoutes(m *macaron.Macaron) {
        }, reqSignIn)
 
        // ***** Release Attachment Download without Signin
-       m.Get("/:username/:reponame/releases/download/:vTag/:fileName", ignSignIn, context.RepoAssignment(), repo.MustBeNotBare, repo.RedirectDownload)
+       m.Get("/:username/:reponame/releases/download/:vTag/:fileName", ignSignIn, context.RepoAssignment(), repo.MustBeNotEmpty, repo.RedirectDownload)
 
        m.Group("/:username/:reponame", func() {
                m.Group("/settings", func() {
@@ -493,7 +493,7 @@ func RegisterRoutes(m *macaron.Macaron) {
                                m.Combo("").Get(repo.ProtectedBranch).Post(repo.ProtectedBranchPost)
                                m.Combo("/*").Get(repo.SettingsProtectedBranch).
                                        Post(bindIgnErr(auth.ProtectBranchForm{}), repo.SettingsProtectedBranchPost)
-                       }, repo.MustBeNotBare)
+                       }, repo.MustBeNotEmpty)
 
                        m.Group("/hooks", func() {
                                m.Get("", repo.Webhooks)
@@ -607,7 +607,7 @@ func RegisterRoutes(m *macaron.Macaron) {
                                m.Post("/upload-file", repo.UploadFileToServer)
                                m.Post("/upload-remove", bindIgnErr(auth.RemoveUploadFileForm{}), repo.RemoveUploadFileFromServer)
                        }, context.RepoRef(), repo.MustBeEditable, repo.MustBeAbleToUpload)
-               }, reqRepoCodeWriter, repo.MustBeNotBare)
+               }, reqRepoCodeWriter, repo.MustBeNotEmpty)
 
                m.Group("/branches", func() {
                        m.Group("/_new/", func() {
@@ -617,24 +617,24 @@ func RegisterRoutes(m *macaron.Macaron) {
                        }, bindIgnErr(auth.NewBranchForm{}))
                        m.Post("/delete", repo.DeleteBranchPost)
                        m.Post("/restore", repo.RestoreBranchPost)
-               }, reqRepoCodeWriter, repo.MustBeNotBare)
+               }, reqRepoCodeWriter, repo.MustBeNotEmpty)
 
        }, reqSignIn, context.RepoAssignment(), context.UnitTypes())
 
        // Releases
        m.Group("/:username/:reponame", func() {
                m.Group("/releases", func() {
-                       m.Get("/", repo.MustBeNotBare, repo.Releases)
-               }, repo.MustBeNotBare, context.RepoRef())
+                       m.Get("/", repo.MustBeNotEmpty, repo.Releases)
+               }, repo.MustBeNotEmpty, context.RepoRef())
                m.Group("/releases", func() {
                        m.Get("/new", repo.NewRelease)
                        m.Post("/new", bindIgnErr(auth.NewReleaseForm{}), repo.NewReleasePost)
                        m.Post("/delete", repo.DeleteRelease)
-               }, reqSignIn, repo.MustBeNotBare, reqRepoReleaseWriter, context.RepoRef())
+               }, reqSignIn, repo.MustBeNotEmpty, reqRepoReleaseWriter, context.RepoRef())
                m.Group("/releases", func() {
                        m.Get("/edit/*", repo.EditRelease)
                        m.Post("/edit/*", bindIgnErr(auth.EditReleaseForm{}), repo.EditReleasePost)
-               }, reqSignIn, repo.MustBeNotBare, reqRepoReleaseWriter, func(ctx *context.Context) {
+               }, reqSignIn, repo.MustBeNotEmpty, reqRepoReleaseWriter, func(ctx *context.Context) {
                        var err error
                        ctx.Repo.Commit, err = ctx.Repo.GitRepo.GetBranchCommit(ctx.Repo.Repository.DefaultBranch)
                        if err != nil {
@@ -682,13 +682,13 @@ func RegisterRoutes(m *macaron.Macaron) {
                m.Group("/activity", func() {
                        m.Get("", repo.Activity)
                        m.Get("/:period", repo.Activity)
-               }, context.RepoRef(), repo.MustBeNotBare, context.RequireRepoReaderOr(models.UnitTypePullRequests, models.UnitTypeIssues, models.UnitTypeReleases))
+               }, context.RepoRef(), repo.MustBeNotEmpty, context.RequireRepoReaderOr(models.UnitTypePullRequests, models.UnitTypeIssues, models.UnitTypeReleases))
 
-               m.Get("/archive/*", repo.MustBeNotBare, reqRepoCodeReader, repo.Download)
+               m.Get("/archive/*", repo.MustBeNotEmpty, reqRepoCodeReader, repo.Download)
 
                m.Group("/branches", func() {
                        m.Get("", repo.Branches)
-               }, repo.MustBeNotBare, context.RepoRef(), reqRepoCodeReader)
+               }, repo.MustBeNotEmpty, context.RepoRef(), reqRepoCodeReader)
 
                m.Group("/pulls/:index", func() {
                        m.Get(".diff", repo.DownloadPullDiff)
@@ -712,7 +712,7 @@ func RegisterRoutes(m *macaron.Macaron) {
                        m.Get("/blob/:sha", context.RepoRefByType(context.RepoRefBlob), repo.DownloadByID)
                        // "/*" route is deprecated, and kept for backward compatibility
                        m.Get("/*", context.RepoRefByType(context.RepoRefLegacy), repo.SingleDownload)
-               }, repo.MustBeNotBare, reqRepoCodeReader)
+               }, repo.MustBeNotEmpty, reqRepoCodeReader)
 
                m.Group("/commits", func() {
                        m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.RefCommits)
@@ -720,12 +720,12 @@ func RegisterRoutes(m *macaron.Macaron) {
                        m.Get("/commit/*", context.RepoRefByType(context.RepoRefCommit), repo.RefCommits)
                        // "/*" route is deprecated, and kept for backward compatibility
                        m.Get("/*", context.RepoRefByType(context.RepoRefLegacy), repo.RefCommits)
-               }, repo.MustBeNotBare, reqRepoCodeReader)
+               }, repo.MustBeNotEmpty, reqRepoCodeReader)
 
                m.Group("", func() {
                        m.Get("/graph", repo.Graph)
                        m.Get("/commit/:sha([a-f0-9]{7,40})$", repo.SetEditorconfigIfExists, repo.SetDiffViewStyle, repo.Diff)
-               }, repo.MustBeNotBare, context.RepoRef(), reqRepoCodeReader)
+               }, repo.MustBeNotEmpty, context.RepoRef(), reqRepoCodeReader)
 
                m.Group("/src", func() {
                        m.Get("/branch/*", context.RepoRefByType(context.RepoRefBranch), repo.Home)
@@ -739,10 +739,10 @@ func RegisterRoutes(m *macaron.Macaron) {
                        m.Get("/forks", repo.Forks)
                }, context.RepoRef(), reqRepoCodeReader)
                m.Get("/commit/:sha([a-f0-9]{7,40})\\.:ext(patch|diff)",
-                       repo.MustBeNotBare, reqRepoCodeReader, repo.RawDiff)
+                       repo.MustBeNotEmpty, reqRepoCodeReader, repo.RawDiff)
 
                m.Get("/compare/:before([a-z0-9]{40})\\.\\.\\.:after([a-z0-9]{40})", repo.SetEditorconfigIfExists,
-                       repo.SetDiffViewStyle, repo.MustBeNotBare, reqRepoCodeReader, repo.CompareDiff)
+                       repo.SetDiffViewStyle, repo.MustBeNotEmpty, reqRepoCodeReader, repo.CompareDiff)
        }, ignSignIn, context.RepoAssignment(), context.UnitTypes())
        m.Group("/:username/:reponame", func() {
                m.Get("/stars", repo.Stars)
diff --git a/templates/repo/bare.tmpl b/templates/repo/bare.tmpl
deleted file mode 100644 (file)
index ec4be2b..0000000
+++ /dev/null
@@ -1,70 +0,0 @@
-{{template "base/head" .}}
-<div class="repository quickstart">
-       {{template "repo/header" .}}
-       <div class="ui container">
-               <div class="ui grid">
-                       <div class="sixteen wide column content">
-                               {{template "base/alert" .}}
-                               {{if .CanWriteCode}}
-                                       <h4 class="ui top attached header">
-                                               {{.i18n.Tr "repo.quick_guide"}}
-                                       </h4>
-                                       <div class="ui attached guide table segment">
-                                               <div class="item">
-                                                       <h3>{{.i18n.Tr "repo.clone_this_repo"}} <small>{{.i18n.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}</small></h3>
-                                                       <div class="ui action small input">
-                                                               {{if not $.DisableHTTP}}
-                                                                       <button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">
-                                                                               {{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
-                                                                       </button>
-                                                               {{end}}
-                                                               {{if not $.DisableSSH}}
-                                                                       <button class="ui basic clone button" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">
-                                                                               SSH
-                                                                       </button>
-                                                               {{end}}
-                                                               {{if not $.DisableHTTP}}
-                                                                       <input id="repo-clone-url" value="{{$.CloneLink.HTTPS}}" readonly>
-                                                               {{else}}
-                                                                       <input id="repo-clone-url" value="{{$.CloneLink.SSH}}" readonly>
-                                                               {{end}}
-                                                               {{if not (and $.DisableHTTP $.DisableSSH)}}
-                                                                       <button class="ui basic button poping up clipboard" id="clipboard-btn" data-original="{{.i18n.Tr "repo.copy_link"}}" data-success="{{.i18n.Tr "repo.copy_link_success"}}" data-error="{{.i18n.Tr "repo.copy_link_error"}}" data-content="{{.i18n.Tr "repo.copy_link"}}" data-variation="inverted tiny" data-clipboard-target="#repo-clone-url">
-                                                                               <i class="octicon octicon-clippy"></i>
-                                                                       </button>
-                                                               {{end}}
-                                                       </div>
-                                               </div>
-                                               <div class="ui divider"></div>
-
-                                               <div class="item">
-                                                       <h3>{{.i18n.Tr "repo.create_new_repo_command"}}</h3>
-                                                       <div class="markdown">
-                                                               <pre><code>touch README.md
-git init
-git add README.md
-git commit -m "first commit"
-git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
-git push -u origin master</code></pre>
-                                                       </div>
-                                               </div>
-                                               <div class="ui divider"></div>
-
-                                               <div class="item">
-                                                       <h3>{{.i18n.Tr "repo.push_exist_repo"}}</h3>
-                                                       <div class="markdown">
-                                                               <pre><code>git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
-git push -u origin master</code></pre>
-                                                       </div>
-                                               </div>
-                                       {{else}}
-                                               <div class="ui segment center">
-                                                       {{.i18n.Tr "repo.bare_message"}}
-                                               </div>
-                                       {{end}}
-                               </div>
-                       </div>
-               </div>
-       </div>
-</div>
-{{template "base/footer" .}}
diff --git a/templates/repo/empty.tmpl b/templates/repo/empty.tmpl
new file mode 100644 (file)
index 0000000..c213381
--- /dev/null
@@ -0,0 +1,70 @@
+{{template "base/head" .}}
+<div class="repository quickstart">
+       {{template "repo/header" .}}
+       <div class="ui container">
+               <div class="ui grid">
+                       <div class="sixteen wide column content">
+                               {{template "base/alert" .}}
+                               {{if .CanWriteCode}}
+                                       <h4 class="ui top attached header">
+                                               {{.i18n.Tr "repo.quick_guide"}}
+                                       </h4>
+                                       <div class="ui attached guide table segment">
+                                               <div class="item">
+                                                       <h3>{{.i18n.Tr "repo.clone_this_repo"}} <small>{{.i18n.Tr "repo.clone_helper" "http://git-scm.com/book/en/Git-Basics-Getting-a-Git-Repository" | Str2html}}</small></h3>
+                                                       <div class="ui action small input">
+                                                               {{if not $.DisableHTTP}}
+                                                                       <button class="ui basic clone button" id="repo-clone-https" data-link="{{.CloneLink.HTTPS}}">
+                                                                               {{if UseHTTPS}}HTTPS{{else}}HTTP{{end}}
+                                                                       </button>
+                                                               {{end}}
+                                                               {{if not $.DisableSSH}}
+                                                                       <button class="ui basic clone button" id="repo-clone-ssh" data-link="{{.CloneLink.SSH}}">
+                                                                               SSH
+                                                                       </button>
+                                                               {{end}}
+                                                               {{if not $.DisableHTTP}}
+                                                                       <input id="repo-clone-url" value="{{$.CloneLink.HTTPS}}" readonly>
+                                                               {{else}}
+                                                                       <input id="repo-clone-url" value="{{$.CloneLink.SSH}}" readonly>
+                                                               {{end}}
+                                                               {{if not (and $.DisableHTTP $.DisableSSH)}}
+                                                                       <button class="ui basic button poping up clipboard" id="clipboard-btn" data-original="{{.i18n.Tr "repo.copy_link"}}" data-success="{{.i18n.Tr "repo.copy_link_success"}}" data-error="{{.i18n.Tr "repo.copy_link_error"}}" data-content="{{.i18n.Tr "repo.copy_link"}}" data-variation="inverted tiny" data-clipboard-target="#repo-clone-url">
+                                                                               <i class="octicon octicon-clippy"></i>
+                                                                       </button>
+                                                               {{end}}
+                                                       </div>
+                                               </div>
+                                               <div class="ui divider"></div>
+
+                                               <div class="item">
+                                                       <h3>{{.i18n.Tr "repo.create_new_repo_command"}}</h3>
+                                                       <div class="markdown">
+                                                               <pre><code>touch README.md
+git init
+git add README.md
+git commit -m "first commit"
+git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
+git push -u origin master</code></pre>
+                                                       </div>
+                                               </div>
+                                               <div class="ui divider"></div>
+
+                                               <div class="item">
+                                                       <h3>{{.i18n.Tr "repo.push_exist_repo"}}</h3>
+                                                       <div class="markdown">
+                                                               <pre><code>git remote add origin <span class="clone-url">{{if $.DisableSSH}}{{$.CloneLink.HTTPS}}{{else}}{{$.CloneLink.SSH}}{{end}}</span>
+git push -u origin master</code></pre>
+                                                       </div>
+                                               </div>
+                                       {{else}}
+                                               <div class="ui segment center">
+                                                       {{.i18n.Tr "repo.empty_message"}}
+                                               </div>
+                                       {{end}}
+                               </div>
+                       </div>
+               </div>
+       </div>
+</div>
+{{template "base/footer" .}}
index b0ea694ff902939978e4e186a40b78cf970c0c7e..3dc5a40f189b4c3fc2b6a22b7b5a1e9ea9c33770 100644 (file)
@@ -30,7 +30,7 @@
                                                {{.NumStars}}
                                        </a>
                                </div>
-                               {{if and (not .IsBare) ($.Permission.CanRead $.UnitTypeCode)}}
+                               {{if and (not .IsEmpty) ($.Permission.CanRead $.UnitTypeCode)}}
                                        <div class="ui compact labeled button" tabindex="0">
                                                <a class="ui compact button {{if or (not $.IsSigned) (not $.CanSignedUserFork)}}poping up{{end}}" {{if $.CanSignedUserFork}}href="{{AppSubUrl}}/repo/fork/{{.ID}}"{{else if $.IsSigned}} data-content="{{$.i18n.Tr "repo.fork_from_self"}}" {{ else }} data-content="{{$.i18n.Tr "repo.fork_guest_user" }}" href="{{AppSubUrl}}/user/login?redirect_to={{AppSubUrl}}/repo/fork/{{.ID}}" {{end}} data-position="top center" data-variation="tiny">
                                                        <i class="octicon octicon-repo-forked"></i>{{$.i18n.Tr "repo.fork"}}
@@ -71,7 +71,7 @@
                                </a>
                        {{end}}
 
-                       {{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsBareRepo) }}
+                       {{if and (.Permission.CanRead $.UnitTypeReleases) (not .IsEmptyRepo) }}
                        <a class="{{if .PageIsReleaseList}}active{{end}} item" href="{{.RepoLink}}/releases">
                                <i class="octicon octicon-tag"></i> {{.i18n.Tr "repo.releases"}} <span class="ui {{if not .Repository.NumReleases}}gray{{else}}blue{{end}} small label">{{.Repository.NumReleases}}</span>
                        </a>
@@ -83,7 +83,7 @@
                                </a>
                        {{end}}
 
-                       {{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsBareRepo)}}
+                       {{if and (.Permission.CanReadAny $.UnitTypePullRequests $.UnitTypeIssues $.UnitTypeReleases) (not .IsEmptyRepo)}}
                                <a class="{{if .PageIsActivity}}active{{end}} item" href="{{.RepoLink}}/activity">
                                        <i class="octicon octicon-pulse"></i> {{.i18n.Tr "repo.activity"}}
                                </a>
index 6df2517a941afded298eaf54a246189fe231ee32..369f73fcc769921034a9677fc9789a97ccc2a4b1 100644 (file)
@@ -14,7 +14,7 @@
                        <form class="ui form" action="{{.Link}}" method="post">
                                {{.CsrfTokenHtml}}
                                <input type="hidden" name="action" value="default_branch">
-                               {{if not .Repository.IsBare}}
+                               {{if not .Repository.IsEmpty}}
                                <div class="required inline field">
                                        <div class="ui dropdown selection" tabindex="0">
                                                <select name="branch">
index 3d9d7d15a7fcfe8d50f3ccd9d23191b269d90a85..24082000e2ae91434f04a3965f359ed757a412ed 100644 (file)
@@ -5,7 +5,7 @@
        <a class="{{if .PageIsSettingsCollaboration}}active{{end}} item" href="{{.RepoLink}}/settings/collaboration">
                {{.i18n.Tr "repo.settings.collaboration"}}
        </a>
-       {{if not .Repository.IsBare}}
+       {{if not .Repository.IsEmpty}}
                <a class="{{if .PageIsSettingsBranches}}active{{end}} item" href="{{.RepoLink}}/settings/branches">
                        {{.i18n.Tr "repo.settings.branches"}}
                </a>
index 4ca1aa5cbb310030cef01f4143145c2211629cfd..54e219def86422613d3a5cdcc8ee3d81a8bca52b 100644 (file)
@@ -1,11 +1,11 @@
 <div class="ui segment sub-menu">
        <div class="ui two horizontal center link list">
-               {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsBareRepo)}}
+               {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsEmptyRepo)}}
                        <div class="item{{if .PageIsCommits}} active{{end}}">
                                <a href="{{.RepoLink}}/commits{{if .IsViewBranch}}/branch{{else if .IsViewTag}}/tag{{else if .IsViewCommit}}/commit{{end}}/{{EscapePound .BranchName}}"><i class="octicon octicon-history"></i> <b>{{.CommitsCount}}</b> {{.i18n.Tr (TrN .i18n.Lang .CommitsCount "repo.commit" "repo.commits") }}</a>
                        </div>
                {{end}}
-               {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsBareRepo) }}
+               {{if and (.Permission.CanRead $.UnitTypeCode) (not .IsEmptyRepo) }}
                        <div class="item{{if .PageIsBranches}} active{{end}}">
                                <a href="{{.RepoLink}}/branches/"><i class="octicon octicon-git-branch"></i> <b>{{.BranchesCount}}</b> {{.i18n.Tr (TrN .i18n.Lang .BranchesCount "repo.branch" "repo.branches") }}</a>
                        </div>