From 3b3e67f62a8a3afe864ef69fe496bf2c4db8b4e1 Mon Sep 17 00:00:00 2001
From: Brecht Van Lommel <brecht@blender.org>
Date: Thu, 9 Feb 2023 00:10:09 +0100
Subject: [PATCH 1/2] Fix update by rebase being wrongly disabled by protected
 base branch

The branch this is force pushing to is the head branch in the head repo, so
it should be checking if that is protected, not the base.
---
 services/pull/update.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/services/pull/update.go b/services/pull/update.go
index ede89bcdfff3e..5be662908d505 100644
--- a/services/pull/update.go
+++ b/services/pull/update.go
@@ -106,7 +106,7 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
 		BaseBranch: pull.HeadBranch,
 	}
 
-	pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pull.BaseRepoID, pull.BaseBranch)
+	pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pull.HeadRepoID, pull.HeadBranch)
 	if err != nil {
 		return false, false, err
 	}

From 8cdc85c4a5a977d1fd7f061e8aa2f4031a6c87c6 Mon Sep 17 00:00:00 2001
From: Jason Song <i@wolfogre.com>
Date: Thu, 9 Feb 2023 12:07:37 +0800
Subject: [PATCH 2/2] Update services/pull/update.go

---
 services/pull/update.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/services/pull/update.go b/services/pull/update.go
index 5be662908d505..b9525cf0c980f 100644
--- a/services/pull/update.go
+++ b/services/pull/update.go
@@ -106,7 +106,7 @@ func IsUserAllowedToUpdate(ctx context.Context, pull *issues_model.PullRequest,
 		BaseBranch: pull.HeadBranch,
 	}
 
-	pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pull.HeadRepoID, pull.HeadBranch)
+	pb, err := git_model.GetFirstMatchProtectedBranchRule(ctx, pr.BaseRepoID, pr.BaseBranch)
 	if err != nil {
 		return false, false, err
 	}