Skip to content

Fix a bug when forking a repository in an organization#36950

Merged
lunny merged 6 commits into
go-gitea:mainfrom
lunny:lunny/fix_bug
Apr 2, 2026
Merged

Fix a bug when forking a repository in an organization#36950
lunny merged 6 commits into
go-gitea:mainfrom
lunny:lunny/fix_bug

Conversation

@lunny
Copy link
Copy Markdown
Member

@lunny lunny commented Mar 23, 2026

CanCreateOrgRepo should be checked before forking a repository into this organization.


Generated by a coding agent with Codex 5.2

@lunny lunny added type/bug backport/v1.25 This PR should be backported to Gitea 1.25 labels Mar 23, 2026
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 23, 2026
@lunny lunny requested a review from Copilot March 23, 2026 21:08
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an organization permission check to the fork API flow so users without CanCreateOrgRepo cannot fork a repository into an organization.

Changes:

  • Add integration test asserting forking into an org is forbidden when the user lacks org repo-create permission.
  • Enforce CanCreateOrgRepo check in the API fork endpoint before selecting the org as the forker.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
tests/integration/api_fork_test.go Adds coverage for forking into an org when the caller lacks create-repo permission.
routers/api/v1/repo/fork.go Adds org repo-create permission gating before allowing forks into an organization.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread routers/api/v1/repo/fork.go Outdated
Comment thread routers/api/v1/repo/fork.go Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Lunny Xiao <xiaolunwen@gmail.com>
@wxiaoguang wxiaoguang removed the backport/v1.25 This PR should be backported to Gitea 1.25 label Mar 27, 2026
@lunny lunny added this to the 1.26.0 milestone Apr 1, 2026
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Apr 1, 2026
Comment thread routers/api/v1/repo/fork.go Outdated
@wxiaoguang
Copy link
Copy Markdown
Contributor

Cleaned up AI slop.

HasOrgOrUserVisible was missing
IsErrOrgNotExist then StatusUnprocessableEntity is wrong
APIErrorNotFound with user message is wrong

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Apr 2, 2026
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 2, 2026
@lunny lunny merged commit 686d10b into go-gitea:main Apr 2, 2026
26 checks passed
@lunny lunny deleted the lunny/fix_bug branch April 2, 2026 22:04
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Apr 2, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Apr 3, 2026
* main:
  Fix RPM Registry 404 when package name contains 'package' (go-gitea#37087)
  Improve actions notifier for `workflow_run` (go-gitea#37088)
  Refactor code render and render control chars (go-gitea#37078)
  Fix various problems (go-gitea#37077)
  [skip ci] Updated translations via Crowdin
  Support legacy run/job index-based URLs and refactor migration 326 (go-gitea#37008)
  Fix a bug when forking a repository in an organization (go-gitea#36950)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants