Skip to content

fix(web): populate the reason for "cannot commit to branch" in web editor commit form - #39155

Merged
bircni merged 8 commits into
go-gitea:mainfrom
Nitish-1303:fix/editor-cannot-commit-reasons
Aug 28, 2026
Merged

fix(web): populate the reason for "cannot commit to branch" in web editor commit form#39155
bircni merged 8 commits into
go-gitea:mainfrom
Nitish-1303:fix/editor-cannot-commit-reasons

Conversation

@Nitish-1303

@Nitish-1303 Nitish-1303 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Fixes #38710. PrepareCommitFormOptions now builds DenyCommitToBranchReason on the backend, the template renders it.

By the way, refactor some CanContentChange related legacy code

Fixes go-gitea#38710. When a user edits via fork (code:read on upstream), the disabled direct-commit option showed an empty reason list because the template only checked push permission on the fork. PrepareCommitFormOptions now builds CannotCommitReasons on the backend and the template renders them.
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Aug 27, 2026
@wxiaoguang

Copy link
Copy Markdown
Contributor

The logic should be exactly the same as canCommitToBranch

if ... {
  if .. {
     canCommitToBranch = true
  } else {
     reason = ...
  }
}

@wxiaoguang
wxiaoguang marked this pull request as draft August 27, 2026 14:01
@wxiaoguang
wxiaoguang marked this pull request as ready for review August 28, 2026 11:14
@wxiaoguang wxiaoguang changed the title fix(web): populate CannotCommitReasons in web editor commit form fix(web): populate the reason for "cannot commit to branch" in web editor commit form Aug 28, 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 Aug 28, 2026
@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 Aug 28, 2026
@bircni bircni added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 28, 2026
@bircni
bircni enabled auto-merge (squash) August 28, 2026 20:57
@bircni
bircni merged commit e806566 into go-gitea:main Aug 28, 2026
23 checks passed
@GiteaBot GiteaBot added this to the 28.0.0 milestone Aug 28, 2026
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Aug 28, 2026
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 29, 2026
* 'main' of https://github.com/go-gitea/gitea:
  feat(web): Add org removal functionality to admin user details page (go-gitea#38013)
  fix(actions): run every due schedule exactly once per occurrence (go-gitea#39078)
  refactor: pagination/pager (go-gitea#39162)
  [skip ci] Updated translations via Crowdin
  enhance(actions): make workflow dispatch choice dropdown support search (go-gitea#39154)
  fix(web): populate the reason for "cannot commit to branch" in web editor commit form (go-gitea#39155)
  refactor(automerge): fix error handling, populate recent automerge tasks on restart (go-gitea#39001)
  chore(frontend): avoid loading CSS twice in vite dev mode (go-gitea#39160)
zjjhot added a commit to zjjhot/gitea that referenced this pull request Aug 29, 2026
* main:
  feat(web): Add org removal functionality to admin user details page (go-gitea#38013)
  fix(actions): run every due schedule exactly once per occurrence (go-gitea#39078)
  refactor: pagination/pager (go-gitea#39162)
  [skip ci] Updated translations via Crowdin
  enhance(actions): make workflow dispatch choice dropdown support search (go-gitea#39154)
  fix(web): populate the reason for "cannot commit to branch" in web editor commit form (go-gitea#39155)
  refactor(automerge): fix error handling, populate recent automerge tasks on restart (go-gitea#39001)
  chore(frontend): avoid loading CSS twice in vite dev mode (go-gitea#39160)
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.

Missing reasons on error message Unable to commit directly to branch using web editor with code:read permissions for upstream

4 participants