[PR #3544] [MERGED] Added checks for protected branches in pull requests #16987

Closed
opened 2025-11-02 12:23:38 -06:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/go-gitea/gitea/pull/3544
Author: @Chri-s
Created: 2/19/2018
Status: Merged
Merged: 3/13/2018
Merged by: @lunny

Base: masterHead: master


📝 Commits (10+)

  • fed2b26 Added checks for protected branches in pull requests
  • 1c46c68 Moved check for protected branch into new function CheckUserAllowedToMerge
  • c71f689 Removed merge conflict lines from last commit
  • ebaa008 Explicit check for error type in ViewIssue
  • cdbfa25 Merge branch 'master' into master
  • 8335097 Merge branch 'master' into master
  • a1ee345 Merge branch 'master' into master
  • de829b0 Merge branch 'master' into master
  • 116b91d Merge branch 'master' into master
  • fbf9bf2 Merge branch 'master' into master

📊 Changes

4 files changed (+54 additions, -1 deletions)

View changed files

📝 models/error.go (+15 -0)
📝 models/pull.go (+29 -0)
📝 routers/repo/issue.go (+9 -0)
📝 templates/repo/issue/view_content/pull.tmpl (+1 -1)

📄 Description

Fixes #2875. This pull request adds checks whether the user is allowed to push to the base branch of a pull request.

If a user may not push to the base branch, the green merge button is hidden on the pull request view. If the user tries merge via the web api, an error (http code 500) with
{"message":"branch is protected [name: %s]","url":"https://godoc.org/github.com/go-gitea/go-sdk/gitea"}
is returned.

There shouldn't be a way to circumvent the branch protection via a pull request.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/go-gitea/gitea/pull/3544 **Author:** [@Chri-s](https://github.com/Chri-s) **Created:** 2/19/2018 **Status:** ✅ Merged **Merged:** 3/13/2018 **Merged by:** [@lunny](https://github.com/lunny) **Base:** `master` ← **Head:** `master` --- ### 📝 Commits (10+) - [`fed2b26`](https://github.com/go-gitea/gitea/commit/fed2b2657dfde2af6ed4fc7b32f349ee65405749) Added checks for protected branches in pull requests - [`1c46c68`](https://github.com/go-gitea/gitea/commit/1c46c68526bde0927489bbed1ebcd0f4d90f225e) Moved check for protected branch into new function CheckUserAllowedToMerge - [`c71f689`](https://github.com/go-gitea/gitea/commit/c71f689e86fccd638914f2c0c7cd215650855c50) Removed merge conflict lines from last commit - [`ebaa008`](https://github.com/go-gitea/gitea/commit/ebaa0086926eef1c894918907e587750ef90fd1d) Explicit check for error type in ViewIssue - [`cdbfa25`](https://github.com/go-gitea/gitea/commit/cdbfa256b950e8b7193e5e72ad4837cf4a374304) Merge branch 'master' into master - [`8335097`](https://github.com/go-gitea/gitea/commit/8335097d20cbf664213a35707dbd8894a1f8fa85) Merge branch 'master' into master - [`a1ee345`](https://github.com/go-gitea/gitea/commit/a1ee345ef6f32a0a65f434a767f0e93db0e66bd6) Merge branch 'master' into master - [`de829b0`](https://github.com/go-gitea/gitea/commit/de829b09be91a7b7ca5cc368ccab5ce6ea79419d) Merge branch 'master' into master - [`116b91d`](https://github.com/go-gitea/gitea/commit/116b91d665f8a83dd20f454da44e7905c03b165c) Merge branch 'master' into master - [`fbf9bf2`](https://github.com/go-gitea/gitea/commit/fbf9bf297c9ab190b870d3f0143dd63a96d54071) Merge branch 'master' into master ### 📊 Changes **4 files changed** (+54 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `models/error.go` (+15 -0) 📝 `models/pull.go` (+29 -0) 📝 `routers/repo/issue.go` (+9 -0) 📝 `templates/repo/issue/view_content/pull.tmpl` (+1 -1) </details> ### 📄 Description Fixes #2875. This pull request adds checks whether the user is allowed to push to the base branch of a pull request. If a user may not push to the base branch, the green merge button is hidden on the pull request view. If the user tries merge via the web api, an error (http code 500) with `{"message":"branch is protected [name: %s]","url":"https://godoc.org/github.com/go-gitea/go-sdk/gitea"}` is returned. There shouldn't be a way to circumvent the branch protection via a pull request. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2025-11-02 12:23:38 -06:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea#16987