Conversation
…anonymous embedding Change the anonymous `access_model.Permission` field to a named `Permission access_model.Permission` field in the `Repository` struct in services/context/repo.go. Update all callers that previously accessed the promoted methods directly (e.g. `ctx.Repo.IsAdmin()`) to go through the named field (e.g. `ctx.Repo.Permission.IsAdmin()`). Also fix `CanWriteToBranch` which is a method on `*Repository` (not on `Permission`) and must not be prefixed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> Agent-Logs-Url: https://github.com/go-gitea/gitea/sessions/204bbaf4-671f-4d10-adee-5ad1d4170a6d Co-authored-by: wxiaoguang <2114189+wxiaoguang@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
wxiaoguang
April 26, 2026 17:45
View session
Contributor
|
"Restrict permission check on repositories and fix some problems (#5314)" made the Permission field anonymous, then the code became difficult to understand or maintain. This PR introduces a proper name for the field.
|
wxiaoguang
approved these changes
Apr 26, 2026
lunny
approved these changes
Apr 26, 2026
bircni
approved these changes
Apr 26, 2026
zjjhot
added a commit
to zjjhot/gitea
that referenced
this pull request
Apr 27, 2026
* main: (33 commits) refactor: use named `Permission` field in `Repository` struct instead of anonymous embedding (go-gitea#37441) Refactor pull request view (3) (go-gitea#37439) Update 1.26.1 changelog in main (go-gitea#37442) Make GetPossibleUserByID can handle deleted user (go-gitea#37430) Fix fetch action redirect (go-gitea#37437) Refactor integration test DecodeJSON calls to use generic return value (go-gitea#37432) Integrate renovate bot for all dependency updates (go-gitea#37050) Refactor pull request view (2) (go-gitea#37428) Use MarkLongPolling instead of hard-coded route path (go-gitea#37427) Optimize CI caches (go-gitea#37387) Update AGENTS.md (go-gitea#37420) Update Nix flake (go-gitea#37425) [skip ci] Updated translations via Crowdin remove excessive quote from terraform instructions (go-gitea#37424) Improve testing init, clean up webhook tests (go-gitea#37412) Fix color regressions, add `priority` color (go-gitea#37417) [skip ci] Updated translations via Crowdin Stabilize e2e logout propagation test (go-gitea#37403) refactor: serve site manifest via `/assets/site-manifest.json` endpoint (go-gitea#37405) feat(security): set X-Content-Type-Options: nosniff by default (go-gitea#37354) ...
silverwind
added a commit
to hanism01/gitea
that referenced
this pull request
Apr 27, 2026
…-review-feedback * origin/main: (144 commits) Add API endpoint to reply to pull request review comments (go-gitea#36683) Add CurrentURL template variable back (go-gitea#37444) refactor: use named `Permission` field in `Repository` struct instead of anonymous embedding (go-gitea#37441) Refactor pull request view (3) (go-gitea#37439) Update 1.26.1 changelog in main (go-gitea#37442) Make GetPossibleUserByID can handle deleted user (go-gitea#37430) Fix fetch action redirect (go-gitea#37437) Refactor integration test DecodeJSON calls to use generic return value (go-gitea#37432) Integrate renovate bot for all dependency updates (go-gitea#37050) Refactor pull request view (2) (go-gitea#37428) Use MarkLongPolling instead of hard-coded route path (go-gitea#37427) Optimize CI caches (go-gitea#37387) Update AGENTS.md (go-gitea#37420) Update Nix flake (go-gitea#37425) [skip ci] Updated translations via Crowdin remove excessive quote from terraform instructions (go-gitea#37424) Improve testing init, clean up webhook tests (go-gitea#37412) Fix color regressions, add `priority` color (go-gitea#37417) [skip ci] Updated translations via Crowdin Stabilize e2e logout propagation test (go-gitea#37403) ... # Conflicts: # models/project/column.go # routers/web/repo/issue_page_meta.go
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The
Repositorystruct inservices/context/repo.goembeddedaccess_model.Permissionanonymously, causing all permission methods to be promoted directly ontoRepository. This made it unclear at call sites whether a method belonged toRepositoryitself or to its embeddedPermission.Changes
services/context/repo.go: Replace anonymousaccess_model.Permissionwith named fieldPermission access_model.PermissionMethods defined directly on
*Repository(CanWriteToBranch,CanCreateBranch, etc.) are unchanged.