Skip to content

Commit 66ed233

Browse files
committed
Merge branch 'master' into team_mention_tribute
2 parents 8e39d06 + 1b1adab commit 66ed233

File tree

19 files changed

+60
-13
lines changed

19 files changed

+60
-13
lines changed

custom/conf/app.example.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ DEFAULT_REPO_UNITS = repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,re
6666
PREFIX_ARCHIVE_FILES = true
6767
; Disable the creation of new mirrors. Pre-existing mirrors remain valid.
6868
DISABLE_MIRRORS = false
69+
; Disable migrating feature.
70+
DISABLE_MIGRATIONS = false
6971
; The default branch name of new repositories
7072
DEFAULT_BRANCH = master
7173
; Allow adoption of unadopted repositories

docs/content/doc/advanced/config-cheat-sheet.en-us.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
7474
- `DEFAULT_REPO_UNITS`: **repo.code,repo.releases,repo.issues,repo.pulls,repo.wiki,repo.projects**: Comma separated list of default repo units. Allowed values: \[repo.code, repo.releases, repo.issues, repo.pulls, repo.wiki, repo.projects\]. Note: Code and Releases can currently not be deactivated. If you specify default repo units you should still list them for future compatibility. External wiki and issue tracker can't be enabled by default as it requires additional settings. Disabled repo units will not be added to new repositories regardless if it is in the default list.
7575
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
7676
- `DISABLE_MIRRORS`: **false**: Disable the creation of **new** mirrors. Pre-existing mirrors remain valid.
77+
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
7778
- `DEFAULT_BRANCH`: **master**: Default branch name of all repositories.
7879
- `ALLOW_ADOPTION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to adopt unadopted repositories
7980
- `ALLOW_DELETION_OF_UNADOPTED_REPOSITORIES`: **false**: Allow non-admin users to delete unadopted repositories

integrations/api_settings_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ func TestAPIExposedSettings(t *testing.T) {
4343

4444
DecodeJSON(t, resp, &repo)
4545
assert.EqualValues(t, &api.GeneralRepoSettings{
46-
MirrorsDisabled: setting.Repository.DisableMirrors,
47-
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
46+
MirrorsDisabled: setting.Repository.DisableMirrors,
47+
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
48+
MigrationsDisabled: setting.Repository.DisableMigrations,
4849
}, repo)
4950

5051
attachment := new(api.GeneralAttachmentSettings)

modules/context/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,7 @@ func Contexter() macaron.Handler {
343343

344344
ctx.Data["EnableSwagger"] = setting.API.EnableSwagger
345345
ctx.Data["EnableOpenIDSignIn"] = setting.Service.EnableOpenIDSignIn
346+
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
346347

347348
c.Map(ctx)
348349
}

modules/cron/tasks_basic.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import (
1111
"code.gitea.io/gitea/models"
1212
"code.gitea.io/gitea/modules/migrations"
1313
repository_service "code.gitea.io/gitea/modules/repository"
14+
"code.gitea.io/gitea/modules/setting"
1415
mirror_service "code.gitea.io/gitea/services/mirror"
1516
)
1617

@@ -115,5 +116,7 @@ func initBasicTasks() {
115116
registerArchiveCleanup()
116117
registerSyncExternalUsers()
117118
registerDeletedBranchesCleanup()
118-
registerUpdateMigrationPosterID()
119+
if !setting.Repository.DisableMigrations {
120+
registerUpdateMigrationPosterID()
121+
}
119122
}

modules/setting/repository.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ var (
4242
DefaultRepoUnits []string
4343
PrefixArchiveFiles bool
4444
DisableMirrors bool
45+
DisableMigrations bool
4546
DefaultBranch string
4647
AllowAdoptionOfUnadoptedRepositories bool
4748
AllowDeleteOfUnadoptedRepositories bool
@@ -152,6 +153,7 @@ var (
152153
DefaultRepoUnits: []string{},
153154
PrefixArchiveFiles: true,
154155
DisableMirrors: false,
156+
DisableMigrations: false,
155157
DefaultBranch: "master",
156158

157159
// Repository editor settings

modules/structs/settings.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@ package structs
66

77
// GeneralRepoSettings contains global repository settings exposed by API
88
type GeneralRepoSettings struct {
9-
MirrorsDisabled bool `json:"mirrors_disabled"`
10-
HTTPGitDisabled bool `json:"http_git_disabled"`
9+
MirrorsDisabled bool `json:"mirrors_disabled"`
10+
HTTPGitDisabled bool `json:"http_git_disabled"`
11+
MigrationsDisabled bool `json:"migrations_disabled"`
1112
}
1213

1314
// GeneralUISettings contains global ui settings exposed by API

options/locale/locale_cs-CZ.ini

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ issues.start_tracking_short=Start
11301130
issues.start_tracking=Spustit sledování času
11311131
issues.start_tracking_history=`započal(a) práci %s`
11321132
issues.tracker_auto_close=Časovač se automaticky zastaví po zavření tohoto úkolu
1133+
issues.tracking_already_started=`Již jste spustili sledování času na <a href="%s">jiném úkolu</a>!`
11331134
issues.stop_tracking=Stop
11341135
issues.stop_tracking_history=`ukončil(a) práci %s`
11351136
issues.add_time=Přidat čas ručně
@@ -1785,6 +1786,7 @@ diff.whitespace_ignore_all_whitespace=Ignorovat bílé znaky při porovnávání
17851786
diff.whitespace_ignore_amount_changes=Ignorovat změny v množství bílých znaků
17861787
diff.whitespace_ignore_at_eol=Ignorovat změny v bílých znacích na konci řídku
17871788
diff.stats_desc=<strong> %d změnil soubory</strong>, kde provedl <strong>%d přidání</strong> a <strong>%d odebrání</strong>
1789+
diff.stats_desc_file=%d změn: %d přidání a %d smazání
17881790
diff.bin=binární
17891791
diff.view_file=Zobrazit soubor
17901792
diff.file_before=Před
@@ -1805,7 +1807,7 @@ diff.review.header=Odeslat posouzení
18051807
diff.review.placeholder=Posoudit komentář
18061808
diff.review.comment=Okomentovat
18071809
diff.review.approve=Schválit
1808-
diff.review.reject=Požadované změny
1810+
diff.review.reject=Požadovat změny
18091811
diff.committed_by=odevzdal
18101812
diff.protected=Chráněno
18111813

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ email_notifications.submit = Set Email Preference
654654

655655
[repo]
656656
owner = Owner
657+
owner_helper = Some organizations may not show up in the dropdown due to a maximum repository count limit.
657658
repo_name = Repository Name
658659
repo_name_helper = Good repository names use short, memorable and unique keywords.
659660
repo_size = Repository Size

options/locale/locale_tr-TR.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1130,6 +1130,7 @@ issues.start_tracking_short=Başlat
11301130
issues.start_tracking=Zaman İzlemeyi Başlat
11311131
issues.start_tracking_history=`%s çalışma başlattı`
11321132
issues.tracker_auto_close=Bu konu kapatıldığında zamanlayıcı otomatik olarak durur
1133+
issues.tracking_already_started=`<a href="%s">başka bir konuda</a> zaten zaman izleyici başlattınız!`
11331134
issues.stop_tracking=Durdur
11341135
issues.stop_tracking_history=`%s çalışmayı durdurdu`
11351136
issues.add_time=El ile Zaman Ekle

options/locale/locale_zh-TW.ini

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -652,6 +652,7 @@ email_notifications.submit=套用郵件偏好設定
652652

653653
[repo]
654654
owner=擁有者
655+
owner_helper=組織可能因為儲存庫數量上限而未列入此選單。
655656
repo_name=儲存庫名稱
656657
repo_name_helper=好的儲存庫名稱通常是簡短的、好記的、且獨特的。
657658
repo_size=儲存庫大小
@@ -1129,6 +1130,7 @@ issues.start_tracking_short=開始
11291130
issues.start_tracking=開始時間追蹤
11301131
issues.start_tracking_history=`開始工作 %s`
11311132
issues.tracker_auto_close=當這個問題被關閉時,自動停止計時器
1133+
issues.tracking_already_started=`您已在<a href="%s">另一個問題</a>上開始時間追蹤!`
11321134
issues.stop_tracking=停止
11331135
issues.stop_tracking_history=`結束工作 %s`
11341136
issues.add_time=手動新增時間

routers/admin/users.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ func EditUser(ctx *context.Context) {
191191
ctx.Data["PageIsAdmin"] = true
192192
ctx.Data["PageIsAdminUsers"] = true
193193
ctx.Data["DisableRegularOrgCreation"] = setting.Admin.DisableRegularOrgCreation
194+
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
194195

195196
prepareUserInfo(ctx)
196197
if ctx.Written() {
@@ -205,6 +206,7 @@ func EditUserPost(ctx *context.Context, form auth.AdminEditUserForm) {
205206
ctx.Data["Title"] = ctx.Tr("admin.users.edit_account")
206207
ctx.Data["PageIsAdmin"] = true
207208
ctx.Data["PageIsAdminUsers"] = true
209+
ctx.Data["DisableMigrations"] = setting.Repository.DisableMigrations
208210

209211
u := prepareUserInfo(ctx)
210212
if ctx.Written() {

routers/api/v1/repo/migrate.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,11 @@ func Migrate(ctx *context.APIContext, form api.MigrateRepoOptions) {
119119
return
120120
}
121121

122+
if setting.Repository.DisableMigrations {
123+
ctx.Error(http.StatusForbidden, "MigrationsGlobalDisabled", fmt.Errorf("the site administrator has disabled migrations"))
124+
return
125+
}
126+
122127
var opts = migrations.MigrateOptions{
123128
CloneAddr: remoteAddr,
124129
RepoName: form.RepoName,

routers/api/v1/settings/settings.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ func GetGeneralRepoSettings(ctx *context.APIContext) {
5757
// "200":
5858
// "$ref": "#/responses/GeneralRepoSettings"
5959
ctx.JSON(http.StatusOK, api.GeneralRepoSettings{
60-
MirrorsDisabled: setting.Repository.DisableMirrors,
61-
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
60+
MirrorsDisabled: setting.Repository.DisableMirrors,
61+
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
62+
MigrationsDisabled: setting.Repository.DisableMigrations,
6263
})
6364
}
6465

routers/repo/migrate.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
package repo
77

88
import (
9+
"net/http"
910
"strings"
1011

1112
"code.gitea.io/gitea/models"
@@ -25,6 +26,11 @@ const (
2526

2627
// Migrate render migration of repository page
2728
func Migrate(ctx *context.Context) {
29+
if setting.Repository.DisableMigrations {
30+
ctx.Error(http.StatusForbidden, "Migrate: the site administrator has disabled migrations")
31+
return
32+
}
33+
2834
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
2935
serviceType := ctx.QueryInt("service_type")
3036
if serviceType == 0 {
@@ -60,6 +66,11 @@ func Migrate(ctx *context.Context) {
6066
}
6167

6268
func handleMigrateError(ctx *context.Context, owner *models.User, err error, name string, tpl base.TplName, form *auth.MigrateRepoForm) {
69+
if setting.Repository.DisableMigrations {
70+
ctx.Error(http.StatusForbidden, "MigrateError: the site administrator has disabled migrations")
71+
return
72+
}
73+
6374
switch {
6475
case migrations.IsRateLimitError(err):
6576
ctx.RenderWithErr(ctx.Tr("form.visit_rate_limit"), tpl, form)
@@ -107,6 +118,11 @@ func handleMigrateError(ctx *context.Context, owner *models.User, err error, nam
107118

108119
// MigratePost response for migrating from external git repository
109120
func MigratePost(ctx *context.Context, form auth.MigrateRepoForm) {
121+
if setting.Repository.DisableMigrations {
122+
ctx.Error(http.StatusForbidden, "MigratePost: the site administrator has disabled migrations")
123+
return
124+
}
125+
110126
ctx.Data["Title"] = ctx.Tr("new_migrate")
111127
// Plain git should be first
112128
ctx.Data["service"] = structs.GitServiceType(form.Service)

templates/admin/user/edit.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@
9595
<input name="allow_git_hook" type="checkbox" {{if .User.CanEditGitHook}}checked{{end}} {{if DisableGitHooks}}disabled{{end}}>
9696
</div>
9797
</div>
98-
<div class="inline field">
98+
<div class="inline field" {{if or (DisableImportLocal) (.DisableMigrations)}}hidden{{end}}>
9999
<div class="ui checkbox">
100100
<label><strong>{{.i18n.Tr "admin.users.allow_import_local"}}</strong></label>
101101
<input name="allow_import_local" type="checkbox" {{if .User.CanImportLocal}}checked{{end}} {{if DisableImportLocal}}disabled{{end}}>

templates/base/head_navbar.tmpl

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,11 @@
8989
<a class="item" href="{{AppSubUrl}}/repo/create">
9090
<span class="fitted">{{svg "octicon-plus"}}</span> {{.i18n.Tr "new_repo"}}
9191
</a>
92-
<a class="item" href="{{AppSubUrl}}/repo/migrate">
93-
<span class="fitted">{{svg "octicon-repo-push"}}</span> {{.i18n.Tr "new_migrate"}}
94-
</a>
92+
{{if not .DisableMigrations}}
93+
<a class="item" href="{{AppSubUrl}}/repo/migrate">
94+
<span class="fitted">{{svg "octicon-repo-push"}}</span> {{.i18n.Tr "new_migrate"}}
95+
</a>
96+
{{end}}
9597
{{if .SignedUser.CanCreateOrganization}}
9698
<a class="item" href="{{AppSubUrl}}/org/create">
9799
<span class="fitted">{{svg "octicon-organization"}}</span> {{.i18n.Tr "new_org"}}

templates/repo/create.tmpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
{{end}}
3232
</div>
3333
</div>
34-
<span class="help">Some organizations may not show up in the dropdown due to a maximum repository count limit</span>
34+
<span class="help">{{.i18n.Tr "repo.owner_helper"}}</span>
3535
</div>
3636

3737
<div class="inline required field {{if .Err_RepoName}}error{{end}}">

templates/swagger/v1_json.tmpl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13688,6 +13688,10 @@
1368813688
"type": "boolean",
1368913689
"x-go-name": "HTTPGitDisabled"
1369013690
},
13691+
"migrations_disabled": {
13692+
"type": "boolean",
13693+
"x-go-name": "MigrationsDisabled"
13694+
},
1369113695
"mirrors_disabled": {
1369213696
"type": "boolean",
1369313697
"x-go-name": "MirrorsDisabled"

0 commit comments

Comments
 (0)