-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Require additional user confirmation for making repo private #36959
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ef9b548
dd0fd6c
e485672
f1830eb
dee7da8
ecc77cd
da82ae7
46a9e52
60301e6
6e27238
ca31273
2fd8c11
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <div class="field"> | ||
| <label> | ||
| {{ctx.Locale.Tr "repo.settings.transfer_form_title"}} | ||
|
techknowlogick marked this conversation as resolved.
Outdated
|
||
| <span class="tw-text-red">{{.RepoName}}</span> | ||
| </label> | ||
| </div> | ||
| <div class="required field"> | ||
| <label for="{{.InputID}}">{{ctx.Locale.Tr "repo.repo_name"}}</label> | ||
| <input id="{{.InputID}}" name="repo_name" required maxlength="100"> | ||
| </div> | ||
|
techknowlogick marked this conversation as resolved.
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,66 @@ | ||
| // Copyright 2026 The Gitea Authors. All rights reserved. | ||
| // SPDX-License-Identifier: MIT | ||
|
|
||
| package integration | ||
|
|
||
| import ( | ||
| "net/http" | ||
| "net/url" | ||
| "testing" | ||
|
|
||
| repo_model "code.gitea.io/gitea/models/repo" | ||
| "code.gitea.io/gitea/models/unittest" | ||
| "code.gitea.io/gitea/tests" | ||
|
|
||
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func TestRepositoryVisibilityChangeRequiresNameWhenMakingPrivate(t *testing.T) { | ||
| onGiteaRun(t, func(t *testing.T, u *url.URL) { | ||
| defer tests.PrepareTestEnv(t)() | ||
|
wxiaoguang marked this conversation as resolved.
Outdated
|
||
|
|
||
| session := loginUser(t, "user2") | ||
|
|
||
| // Wrong name should be rejected with a JSON error | ||
| req := NewRequestWithValues(t, "POST", "/user2/repo1/settings", map[string]string{ | ||
| "action": "visibility", | ||
| "repo_id": "1", | ||
| "confirm_repo_name": "wrong-name", | ||
| }) | ||
| resp := session.MakeRequest(t, req, http.StatusBadRequest) | ||
| assert.Contains(t, resp.Body.String(), "errorMessage") | ||
|
|
||
| repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) | ||
| assert.False(t, repo1.IsPrivate) | ||
|
|
||
| // Correct full name (owner/repo) should succeed with a JSON redirect | ||
| req = NewRequestWithValues(t, "POST", "/user2/repo1/settings", map[string]string{ | ||
| "action": "visibility", | ||
| "repo_id": "1", | ||
| "confirm_repo_name": "user2/repo1", | ||
| }) | ||
| resp = session.MakeRequest(t, req, http.StatusOK) | ||
| assert.Contains(t, resp.Body.String(), "redirect") | ||
|
|
||
| repo1 = unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1}) | ||
| assert.True(t, repo1.IsPrivate) | ||
| }) | ||
| } | ||
|
|
||
| func TestRepositoryVisibilityChangeToPublicDoesNotRequireName(t *testing.T) { | ||
| onGiteaRun(t, func(t *testing.T, u *url.URL) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why it needs
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This review was marked as resolved, but not addressed. I removed the |
||
| defer tests.PrepareTestEnv(t)() | ||
|
|
||
| session := loginUser(t, "user2") | ||
|
|
||
| req := NewRequestWithValues(t, "POST", "/user2/repo2/settings", map[string]string{ | ||
| "action": "visibility", | ||
| "repo_id": "2", | ||
| }) | ||
| resp := session.MakeRequest(t, req, http.StatusOK) | ||
| assert.Contains(t, resp.Body.String(), "redirect") | ||
|
|
||
| repo2 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 2}) | ||
| assert.False(t, repo2.IsPrivate) | ||
| }) | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.