Skip to content

Commit 96e160d

Browse files
committed
really check
Signed-off-by: Andrew Thornton <[email protected]>
1 parent 86a2a29 commit 96e160d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

routers/api/v1/repo/pull.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ func MergePullRequest(ctx *context.APIContext) {
881881

882882
if form.DeleteBranchAfterMerge {
883883
var headRepo *git.Repository
884-
if pr.HeadRepoID == pr.BaseRepoID {
884+
if ctx.Repo != nil && ctx.Repo.Repository != nil && ctx.Repo.Repository.ID == pr.HeadRepoID && ctx.Repo.GitRepo != nil {
885885
headRepo = ctx.Repo.GitRepo
886886
} else {
887887
headRepo, err = git.OpenRepository(pr.HeadRepo.RepoPath())

routers/web/repo/pull.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ func MergePullRequest(ctx *context.Context) {
968968

969969
if form.DeleteBranchAfterMerge {
970970
var headRepo *git.Repository
971-
if pr.HeadRepoID == ctx.Repo.Repository.ID {
971+
if ctx.Repo != nil && ctx.Repo.Repository != nil && pr.HeadRepoID == ctx.Repo.Repository.ID && ctx.Repo.GitRepo != nil {
972972
headRepo = ctx.Repo.GitRepo
973973
} else {
974974
headRepo, err = git.OpenRepository(pr.HeadRepo.RepoPath())
@@ -1189,7 +1189,7 @@ func CleanUpPullRequest(ctx *context.Context) {
11891189
var gitBaseRepo *git.Repository
11901190

11911191
// Assume that the base repo is the current context (almost certainly)
1192-
if ctx.Repo != nil && ctx.Repo.Repository.ID == pr.BaseRepoID && ctx.Repo.GitRepo != nil {
1192+
if ctx.Repo != nil && ctx.Repo.Repository != nil && ctx.Repo.Repository.ID == pr.BaseRepoID && ctx.Repo.GitRepo != nil {
11931193
gitBaseRepo = ctx.Repo.GitRepo
11941194
} else {
11951195
// If not just open it

0 commit comments

Comments
 (0)