aboutsummaryrefslogtreecommitdiffstats
path: root/routers
diff options
context:
space:
mode:
authornorohind <60548839+norohind@users.noreply.github.com>2024-03-17 06:56:49 +0300
committerGitHub <noreply@github.com>2024-03-17 11:56:49 +0800
commited02d1fab85c9b8206c0af84dcfc3792e61609cf (patch)
treefbf1493441ca60421470e45f997474d18aae8551 /routers
parent4e547822f348c2963e0db33135b45d43dfc58df8 (diff)
downloadgitea-ed02d1fab85c9b8206c0af84dcfc3792e61609cf.tar.gz
gitea-ed02d1fab85c9b8206c0af84dcfc3792e61609cf.zip
Fix PR creation via api between branches of same repo with head field namespaced (#26986)
Fix #20175 Current implementation of API does not allow creating pull requests between branches of the same repo when you specify *namespace* (owner of the repo) in `head` field in http request body. --- Although GitHub implementation of API allows performing such action and since Gitea targeting compatibility with GitHub API I see it as an appropriate change. I'm proposing a fix to the described problem and test case which covers this logic. My use-case just in case: https://github.com/go-gitea/gitea/issues/20175#issuecomment-1711283022
Diffstat (limited to 'routers')
-rw-r--r--routers/api/v1/repo/pull.go2
1 files changed, 2 insertions, 0 deletions
diff --git a/routers/api/v1/repo/pull.go b/routers/api/v1/repo/pull.go
index 4cb94b11a2..fc47656072 100644
--- a/routers/api/v1/repo/pull.go
+++ b/routers/api/v1/repo/pull.go
@@ -1068,6 +1068,8 @@ func parseCompareInfo(ctx *context.APIContext, form api.CreatePullRequestOption)
return nil, nil, nil, nil, "", ""
}
headBranch = headInfos[1]
+ // The head repository can also point to the same repo
+ isSameRepo = ctx.Repo.Owner.ID == headUser.ID
} else {
ctx.NotFound()