Skip to content

Commit 81005c8

Browse files
committed
GeneralRepoSettings expose MirrorsDisabled, HTTPGitDisabled, MaxCreationLimit
1 parent 5814079 commit 81005c8

File tree

5 files changed

+81
-0
lines changed

5 files changed

+81
-0
lines changed

modules/structs/settings.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2020 The Gitea Authors. All rights reserved.
2+
// Use of this source code is governed by a MIT-style
3+
// license that can be found in the LICENSE file.
4+
5+
package structs
6+
7+
// GeneralRepoSettings contains general repo settings exposed by api
8+
type GeneralRepoSettings struct {
9+
MirrorsDisabled bool `json:"mirrors_disabled"`
10+
HTTPGitDisabled bool `json:"http_git_disabled"`
11+
MaxCreationLimit int `json:"max_creation_limit"`
12+
}

routers/api/v1/api.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -514,6 +514,7 @@ func RegisterRoutes(m *macaron.Macaron) {
514514
m.Post("/markdown/raw", misc.MarkdownRaw)
515515
m.Group("/settings", func() {
516516
m.Get("/allowed_reactions", misc.SettingGetsAllowedReactions)
517+
m.Get("/repository", misc.GetGeneralRepoSettings)
517518
})
518519

519520
// Notifications

routers/api/v1/misc/settings.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99

1010
"code.gitea.io/gitea/modules/context"
1111
"code.gitea.io/gitea/modules/setting"
12+
api "code.gitea.io/gitea/modules/structs"
1213
)
1314

1415
// SettingGetsAllowedReactions return allowed reactions
@@ -23,3 +24,20 @@ func SettingGetsAllowedReactions(ctx *context.APIContext) {
2324
// "$ref": "#/responses/StringSlice"
2425
ctx.JSON(http.StatusOK, setting.UI.Reactions)
2526
}
27+
28+
// GetGeneralRepoSettings return general repo settings
29+
func GetGeneralRepoSettings(ctx *context.APIContext) {
30+
// swagger:operation GET /settings/repository miscellaneous getGeneralRepositorySettings
31+
// ---
32+
// summary: get general repo settings
33+
// produces:
34+
// - application/json
35+
// responses:
36+
// "200":
37+
// "$ref": "#/responses/GeneralRepoSettings"
38+
ctx.JSON(http.StatusOK, api.GeneralRepoSettings{
39+
MirrorsDisabled: setting.Repository.DisableMirrors,
40+
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
41+
MaxCreationLimit: setting.Repository.MaxCreationLimit,
42+
})
43+
}

routers/api/v1/swagger/misc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,10 @@ type swaggerResponseStringSlice struct {
2121
// in:body
2222
Body []string `json:"body"`
2323
}
24+
25+
// GeneralRepoSettings
26+
// swagger:response GeneralRepoSettings
27+
type swaggerResponseGeneralRepoSettings struct {
28+
// in:body
29+
Body api.GeneralRepoSettings `json:"body"`
30+
}

templates/swagger/v1_json.tmpl

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8487,6 +8487,23 @@
84878487
}
84888488
}
84898489
},
8490+
"/settings/repository": {
8491+
"get": {
8492+
"produces": [
8493+
"application/json"
8494+
],
8495+
"tags": [
8496+
"miscellaneous"
8497+
],
8498+
"summary": "get general repo settings",
8499+
"operationId": "getGeneralRepositorySettings",
8500+
"responses": {
8501+
"200": {
8502+
"$ref": "#/responses/GeneralRepoSettings"
8503+
}
8504+
}
8505+
}
8506+
},
84908507
"/signing-key.gpg": {
84918508
"get": {
84928509
"produces": [
@@ -12713,6 +12730,26 @@
1271312730
},
1271412731
"x-go-package": "code.gitea.io/gitea/modules/structs"
1271512732
},
12733+
"GeneralRepoSettings": {
12734+
"description": "GeneralRepoSettings contains general repo settings exposed by api",
12735+
"type": "object",
12736+
"properties": {
12737+
"http_git_disabled": {
12738+
"type": "boolean",
12739+
"x-go-name": "HTTPGitDisabled"
12740+
},
12741+
"max_creation_limit": {
12742+
"type": "integer",
12743+
"format": "int64",
12744+
"x-go-name": "MaxCreationLimit"
12745+
},
12746+
"mirrors_disabled": {
12747+
"type": "boolean",
12748+
"x-go-name": "MirrorsDisabled"
12749+
}
12750+
},
12751+
"x-go-package": "code.gitea.io/gitea/modules/structs"
12752+
},
1271612753
"GitBlobResponse": {
1271712754
"description": "GitBlobResponse represents a git blob",
1271812755
"type": "object",
@@ -14882,6 +14919,12 @@
1488214919
}
1488314920
}
1488414921
},
14922+
"GeneralRepoSettings": {
14923+
"description": "GeneralRepoSettings",
14924+
"schema": {
14925+
"$ref": "#/definitions/GeneralRepoSettings"
14926+
}
14927+
},
1488514928
"GitBlobResponse": {
1488614929
"description": "GitBlobResponse",
1488714930
"schema": {

0 commit comments

Comments
 (0)