-
-
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
Merged
techknowlogick
merged 12 commits into
go-gitea:main
from
techknowlogick:dangerzone-private-enhancement
Mar 24, 2026
Merged
Changes from 5 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
ef9b548
Require additional user confirmation for making repo private
dd0fd6c
update per feedback
e485672
move form into content div
f1830eb
Merge branch 'main' into dangerzone-private-enhancement
techknowlogick dee7da8
Apply suggestion from techknowlogick
techknowlogick ecc77cd
clean up
wxiaoguang da82ae7
clean up
wxiaoguang 46a9e52
clean up
wxiaoguang 60301e6
fix
wxiaoguang 6e27238
clean up
wxiaoguang ca31273
fine tune
wxiaoguang 2fd8c11
Merge branch 'main' into dangerzone-private-enhancement
techknowlogick File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| <div class="field"> | ||
| <label> | ||
| {{ctx.Locale.Tr "repo.settings.enter_repo_name_to_confirm"}} | ||
| <span class="tw-text-red">{{.RepoName}}</span> | ||
| </label> | ||
| </div> | ||
| <div class="required field"> | ||
| <label>{{ctx.Locale.Tr "repo.repo_name"}}</label> | ||
| <input name="repo_name" required maxlength="100"> | ||
| </div> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| // 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 TestRepositoryVisibilityChange(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") | ||
|
|
||
| t.Run("MakePrivateRequiresCorrectName", func(t *testing.T) { | ||
| // 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) | ||
| }) | ||
|
|
||
| t.Run("MakePublicDoesNotRequireName", func(t *testing.T) { | ||
| 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) | ||
| }) | ||
| }) | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.