Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
move disable_mirror from repo to mirror section
  • Loading branch information
6543 committed Sep 4, 2021
commit afd97dde3a69c38058f4eec200e44bb713d346a5
6 changes: 3 additions & 3 deletions custom/conf/app.example.ini
Original file line number Diff line number Diff line change
Expand Up @@ -800,9 +800,6 @@ PATH =
;; Prefix archive files by placing them in a directory named after the repository
;PREFIX_ARCHIVE_FILES = true
;;
;; Disable the creation of new mirrors. Pre-existing mirrors remain valid.
;DISABLE_MIRRORS = false
;;
;; Disable migrating feature.
;DISABLE_MIGRATIONS = false
;;
Expand Down Expand Up @@ -1945,6 +1942,9 @@ PATH =
;[mirror]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Disable the creation of new mirrors. Pre-existing mirrors remain valid.
;ENABLED = true // TODO: CREATE_PULL: true; CREATE_PULL: true
;;
;; Default interval as a duration between each check
;DEFAULT_INTERVAL = 8h
;; Min interval as a duration must be > 1m
Expand Down
2 changes: 1 addition & 1 deletion docs/content/doc/advanced/config-cheat-sheet.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `DISABLED_REPO_UNITS`: **_empty_**: Comma separated list of globally disabled repo units. Allowed values: \[repo.issues, repo.ext_issues, repo.pulls, repo.wiki, repo.ext_wiki, repo.projects\]
- `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.
- `PREFIX_ARCHIVE_FILES`: **true**: Prefix archive files by placing them in a directory named after the repository.
- `DISABLE_MIRRORS`: **false**: Disable the creation of **new** mirrors. Pre-existing mirrors remain valid.
- `DISABLE_MIGRATIONS`: **false**: Disable migrating feature.
- `DISABLE_STARS`: **false**: Disable stars feature.
- `DEFAULT_BRANCH`: **master**: Default branch name of all repositories.
Expand Down Expand Up @@ -955,6 +954,7 @@ Task queue configuration has been moved to `queue.task`. However, the below conf

## Mirror (`mirror`)

- `ENABLED`: **true**: Allow the creation of **new** mirrors. Pre-existing mirrors remain valid.
- `DEFAULT_INTERVAL`: **8h**: Default interval between each check
- `MIN_INTERVAL`: **10m**: Minimum interval for checking. (Must be >1m).

Expand Down
2 changes: 1 addition & 1 deletion integrations/api_settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func TestAPIExposedSettings(t *testing.T) {

DecodeJSON(t, resp, &repo)
assert.EqualValues(t, &api.GeneralRepoSettings{
MirrorsDisabled: setting.Repository.DisableMirrors,
MirrorsDisabled: !setting.Mirror.Enabled,
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
MigrationsDisabled: setting.Repository.DisableMigrations,
TimeTrackingDisabled: false,
Expand Down
2 changes: 0 additions & 2 deletions modules/setting/repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ var (
DisabledRepoUnits []string
DefaultRepoUnits []string
PrefixArchiveFiles bool
DisableMirrors bool
DisableMigrations bool
DisableStars bool `ini:"DISABLE_STARS"`
DefaultBranch string
Expand Down Expand Up @@ -155,7 +154,6 @@ var (
DisabledRepoUnits: []string{},
DefaultRepoUnits: []string{},
PrefixArchiveFiles: true,
DisableMirrors: false,
DisableMigrations: false,
DisableStars: false,
DefaultBranch: "master",
Expand Down
6 changes: 6 additions & 0 deletions modules/setting/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,8 @@ var (

// Mirror settings
Mirror struct {
Enabled bool
AllowedModes string
DefaultInterval time.Duration
MinInterval time.Duration
}
Expand Down Expand Up @@ -939,6 +941,10 @@ func NewContext() {
newGit()

sec = Cfg.Section("mirror")
Mirror.Enabled = sec.Key("ENABLED").MustBool(
// fallback to old config repository.DISABLE_MIRRORS
!Cfg.Section("repository").Key("DISABLE_MIRRORS").MustBool(false),
)
Mirror.MinInterval = sec.Key("MIN_INTERVAL").MustDuration(10 * time.Minute)
Mirror.DefaultInterval = sec.Key("DEFAULT_INTERVAL").MustDuration(8 * time.Hour)
if Mirror.MinInterval.Minutes() < 1 {
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/repo/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func Migrate(ctx *context.APIContext) {

gitServiceType := convert.ToGitServiceType(form.Service)

if form.Mirror && setting.Repository.DisableMirrors {
if form.Mirror && !setting.Mirror.Enabled {
ctx.Error(http.StatusForbidden, "MirrorsGlobalDisabled", fmt.Errorf("the site administrator has disabled mirrors"))
return
}
Expand Down
2 changes: 1 addition & 1 deletion routers/api/v1/settings/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func GetGeneralRepoSettings(ctx *context.APIContext) {
// "200":
// "$ref": "#/responses/GeneralRepoSettings"
ctx.JSON(http.StatusOK, api.GeneralRepoSettings{
MirrorsDisabled: setting.Repository.DisableMirrors,
MirrorsDisabled: !setting.Mirror.Enabled,
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
MigrationsDisabled: setting.Repository.DisableMigrations,
StarsDisabled: setting.Repository.DisableStars,
Expand Down
2 changes: 1 addition & 1 deletion routers/web/org/home.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ func Home(ctx *context.Context) {
ctx.Data["Members"] = members
ctx.Data["Teams"] = org.Teams

ctx.Data["DisabledMirrors"] = setting.Repository.DisableMirrors
ctx.Data["DisabledMirrors"] = !setting.Mirror.Enabled

pager := context.NewPagination(int(count), setting.UI.User.RepoPagingNum, page, 5)
pager.SetDefaultParams(ctx)
Expand Down
4 changes: 2 additions & 2 deletions routers/web/repo/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func MigratePost(ctx *context.Context) {
RepoName: form.RepoName,
Description: form.Description,
Private: form.Private || setting.Repository.ForcePrivate,
Mirror: form.Mirror && !setting.Repository.DisableMirrors,
Mirror: form.Mirror && setting.Mirror.Enabled,
LFS: form.LFS,
LFSEndpoint: form.LFSEndpoint,
AuthUsername: form.AuthUsername,
Expand Down Expand Up @@ -246,7 +246,7 @@ func setMigrationContextData(ctx *context.Context, serviceType structs.GitServic

ctx.Data["LFSActive"] = setting.LFS.StartServer
ctx.Data["IsForcedPrivate"] = setting.Repository.ForcePrivate
ctx.Data["DisableMirrors"] = setting.Repository.DisableMirrors
ctx.Data["DisableMirrors"] = !setting.Mirror.Enabled

// Plain git should be first
ctx.Data["Services"] = append([]structs.GitServiceType{structs.PlainGitService}, structs.SupportedFullGitService...)
Expand Down
2 changes: 1 addition & 1 deletion routers/web/repo/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func Settings(ctx *context.Context) {
ctx.Data["Title"] = ctx.Tr("repo.settings")
ctx.Data["PageIsSettingsOptions"] = true
ctx.Data["ForcePrivate"] = setting.Repository.ForcePrivate
ctx.Data["DisabledMirrors"] = setting.Repository.DisableMirrors
ctx.Data["DisabledMirrors"] = !setting.Mirror.Enabled
ctx.Data["DefaultMirrorInterval"] = setting.Mirror.DefaultInterval

signing, _ := models.SigningKey(ctx.Repo.Repository.RepoPath())
Expand Down