Merge remote-tracking branch 'upstream/v11.0/forgejo' into v11.0/forgejo
Some checks failed
/ release (push) Has been cancelled
testing / backend-checks (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / security-check (push) Has been cancelled
Some checks failed
/ release (push) Has been cancelled
testing / backend-checks (push) Has been cancelled
testing / frontend-checks (push) Has been cancelled
testing / test-unit (push) Has been cancelled
testing / test-e2e (push) Has been cancelled
testing / test-remote-cacher (redis) (push) Has been cancelled
testing / test-remote-cacher (valkey) (push) Has been cancelled
testing / test-remote-cacher (garnet) (push) Has been cancelled
testing / test-remote-cacher (redict) (push) Has been cancelled
testing / test-mysql (push) Has been cancelled
testing / test-pgsql (push) Has been cancelled
testing / test-sqlite (push) Has been cancelled
testing / security-check (push) Has been cancelled
This commit is contained in:
commit
8c583f63a7
5 changed files with 248 additions and 216 deletions
|
@ -224,10 +224,10 @@ type EditRepoOption struct {
|
||||||
AllowRebaseUpdate *bool `json:"allow_rebase_update,omitempty"`
|
AllowRebaseUpdate *bool `json:"allow_rebase_update,omitempty"`
|
||||||
// set to `true` to delete pr branch after merge by default
|
// set to `true` to delete pr branch after merge by default
|
||||||
DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge,omitempty"`
|
DefaultDeleteBranchAfterMerge *bool `json:"default_delete_branch_after_merge,omitempty"`
|
||||||
// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", or "fast-forward-only".
|
// set to a merge style to be used by this repository: "merge", "rebase", "rebase-merge", "squash", "fast-forward-only", "manually-merged", or "rebase-update-only".
|
||||||
DefaultMergeStyle *string `json:"default_merge_style,omitempty"`
|
DefaultMergeStyle *string `json:"default_merge_style,omitempty" binding:"In(merge,rebase,rebase-merge,squash,fast-forward-only,manually-merged,rebase-update-only)"`
|
||||||
// set to a update style to be used by this repository: "rebase" or "merge"
|
// set to a update style to be used by this repository: "rebase" or "merge"
|
||||||
DefaultUpdateStyle *string `json:"default_update_style,omitempty"`
|
DefaultUpdateStyle *string `json:"default_update_style,omitempty" binding:"In(merge,rebase)"`
|
||||||
// set to `true` to allow edits from maintainers by default
|
// set to `true` to allow edits from maintainers by default
|
||||||
DefaultAllowMaintainerEdit *bool `json:"default_allow_maintainer_edit,omitempty"`
|
DefaultAllowMaintainerEdit *bool `json:"default_allow_maintainer_edit,omitempty"`
|
||||||
// set to `true` to archive this repository.
|
// set to `true` to archive this repository.
|
||||||
|
|
|
@ -105,6 +105,10 @@ func Units(ctx *context.Context) {
|
||||||
|
|
||||||
func UnitsPost(ctx *context.Context) {
|
func UnitsPost(ctx *context.Context) {
|
||||||
form := web.GetForm(ctx).(*forms.RepoUnitSettingForm)
|
form := web.GetForm(ctx).(*forms.RepoUnitSettingForm)
|
||||||
|
if ctx.HasError() {
|
||||||
|
ctx.Redirect(ctx.Repo.Repository.Link() + "/settings/units")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
repo := ctx.Repo.Repository
|
repo := ctx.Repo.Repository
|
||||||
|
|
||||||
|
|
|
@ -188,8 +188,8 @@ type RepoUnitSettingForm struct {
|
||||||
PullsAllowSquash bool
|
PullsAllowSquash bool
|
||||||
PullsAllowFastForwardOnly bool
|
PullsAllowFastForwardOnly bool
|
||||||
PullsAllowManualMerge bool
|
PullsAllowManualMerge bool
|
||||||
PullsDefaultMergeStyle string
|
PullsDefaultMergeStyle string `binding:"In(merge,rebase,rebase-merge,squash,fast-forward-only,manually-merged,rebase-update-only)"`
|
||||||
PullsDefaultUpdateStyle string
|
PullsDefaultUpdateStyle string `binding:"In(merge,rebase)"`
|
||||||
EnableAutodetectManualMerge bool
|
EnableAutodetectManualMerge bool
|
||||||
PullsAllowRebaseUpdate bool
|
PullsAllowRebaseUpdate bool
|
||||||
DefaultDeleteBranchAfterMerge bool
|
DefaultDeleteBranchAfterMerge bool
|
||||||
|
|
2
templates/swagger/v1_json.tmpl
generated
2
templates/swagger/v1_json.tmpl
generated
|
@ -23762,7 +23762,7 @@
|
||||||
"x-go-name": "DefaultDeleteBranchAfterMerge"
|
"x-go-name": "DefaultDeleteBranchAfterMerge"
|
||||||
},
|
},
|
||||||
"default_merge_style": {
|
"default_merge_style": {
|
||||||
"description": "set to a merge style to be used by this repository: \"merge\", \"rebase\", \"rebase-merge\", \"squash\", or \"fast-forward-only\".",
|
"description": "set to a merge style to be used by this repository: \"merge\", \"rebase\", \"rebase-merge\", \"squash\", \"fast-forward-only\", \"manually-merged\", or \"rebase-update-only\".",
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"x-go-name": "DefaultMergeStyle"
|
"x-go-name": "DefaultMergeStyle"
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,6 @@ package integration
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
auth_model "forgejo.org/models/auth"
|
auth_model "forgejo.org/models/auth"
|
||||||
|
@ -16,6 +15,7 @@ import (
|
||||||
"forgejo.org/models/unittest"
|
"forgejo.org/models/unittest"
|
||||||
user_model "forgejo.org/models/user"
|
user_model "forgejo.org/models/user"
|
||||||
api "forgejo.org/modules/structs"
|
api "forgejo.org/modules/structs"
|
||||||
|
"forgejo.org/tests"
|
||||||
|
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
@ -137,7 +137,7 @@ func getNewRepoEditOption(opts *api.EditRepoOption) *api.EditRepoOption {
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestAPIRepoEdit(t *testing.T) {
|
func TestAPIRepoEdit(t *testing.T) {
|
||||||
onGiteaRun(t, func(t *testing.T, u *url.URL) {
|
defer tests.PrepareTestEnv(t)()
|
||||||
bFalse, bTrue := false, true
|
bFalse, bTrue := false, true
|
||||||
|
|
||||||
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) // owner of the repo1 & repo16
|
user2 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 2}) // owner of the repo1 & repo16
|
||||||
|
@ -364,5 +364,33 @@ func TestAPIRepoEdit(t *testing.T) {
|
||||||
req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, repo1.Name), &repoEditOption).
|
req = NewRequestWithJSON(t, "PATCH", fmt.Sprintf("/api/v1/repos/%s/%s", user2.Name, repo1.Name), &repoEditOption).
|
||||||
AddTokenAuth(token4)
|
AddTokenAuth(token4)
|
||||||
MakeRequest(t, req, http.StatusForbidden)
|
MakeRequest(t, req, http.StatusForbidden)
|
||||||
|
|
||||||
|
t.Run("Default merge style", func(t *testing.T) {
|
||||||
|
defer tests.PrintCurrentTest(t)()
|
||||||
|
|
||||||
|
updateStyle := "invalid"
|
||||||
|
MakeRequest(t, NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{
|
||||||
|
DefaultUpdateStyle: &updateStyle,
|
||||||
|
}).AddTokenAuth(token2), http.StatusUnprocessableEntity)
|
||||||
|
|
||||||
|
MakeRequest(t, NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{
|
||||||
|
DefaultMergeStyle: &updateStyle,
|
||||||
|
}).AddTokenAuth(token2), http.StatusUnprocessableEntity)
|
||||||
|
|
||||||
|
var apiRepo api.Repository
|
||||||
|
DecodeJSON(t, MakeRequest(t, NewRequest(t, "GET", url).AddTokenAuth(token2), http.StatusOK), &apiRepo)
|
||||||
|
assert.Equal(t, "merge", apiRepo.DefaultMergeStyle)
|
||||||
|
assert.Equal(t, "merge", apiRepo.DefaultUpdateStyle)
|
||||||
|
|
||||||
|
updateStyle = "rebase"
|
||||||
|
MakeRequest(t, NewRequestWithJSON(t, "PATCH", url, &api.EditRepoOption{
|
||||||
|
DefaultMergeStyle: &updateStyle,
|
||||||
|
DefaultUpdateStyle: &updateStyle,
|
||||||
|
HasPullRequests: &bTrue,
|
||||||
|
}).AddTokenAuth(token2), http.StatusOK)
|
||||||
|
|
||||||
|
DecodeJSON(t, MakeRequest(t, NewRequest(t, "GET", url).AddTokenAuth(token2), http.StatusOK), &apiRepo)
|
||||||
|
assert.Equal(t, "rebase", apiRepo.DefaultMergeStyle)
|
||||||
|
assert.Equal(t, "rebase", apiRepo.DefaultUpdateStyle)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue