Skip to content

Commit cc6b3f6

Browse files
authored
Fix displaying commits and files of PR created from now deleted fork (#2023)
Fix displaying commits and files of PR created from now deleted fork
2 parents 2282475 + 63504bf commit cc6b3f6

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

routers/repo/pull.go

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -256,15 +256,16 @@ func ViewPullCommits(ctx *context.Context) {
256256
return
257257
}
258258
pull := issue.PullRequest
259-
ctx.Data["Username"] = pull.HeadUserName
260-
ctx.Data["Reponame"] = pull.HeadRepo.Name
261259

262260
var commits *list.List
263261
if pull.HasMerged {
264262
PrepareMergedViewPullInfo(ctx, issue)
265263
if ctx.Written() {
266264
return
267265
}
266+
ctx.Data["Username"] = ctx.Repo.Owner.Name
267+
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
268+
268269
startCommit, err := ctx.Repo.GitRepo.GetCommit(pull.MergeBase)
269270
if err != nil {
270271
ctx.Handle(500, "Repo.GitRepo.GetCommit", err)
@@ -280,7 +281,6 @@ func ViewPullCommits(ctx *context.Context) {
280281
ctx.Handle(500, "Repo.GitRepo.CommitsBetween", err)
281282
return
282283
}
283-
284284
} else {
285285
prInfo := PrepareViewPullInfo(ctx, issue)
286286
if ctx.Written() {
@@ -289,6 +289,8 @@ func ViewPullCommits(ctx *context.Context) {
289289
ctx.Handle(404, "ViewPullCommits", nil)
290290
return
291291
}
292+
ctx.Data["Username"] = pull.HeadUserName
293+
ctx.Data["Reponame"] = pull.HeadRepo.Name
292294
commits = prInfo.Commits
293295
}
294296

@@ -319,6 +321,7 @@ func ViewPullFiles(ctx *context.Context) {
319321
gitRepo *git.Repository
320322
)
321323

324+
var headTarget string
322325
if pull.HasMerged {
323326
PrepareMergedViewPullInfo(ctx, issue)
324327
if ctx.Written() {
@@ -329,6 +332,10 @@ func ViewPullFiles(ctx *context.Context) {
329332
startCommitID = pull.MergeBase
330333
endCommitID = pull.MergedCommitID
331334
gitRepo = ctx.Repo.GitRepo
335+
336+
headTarget = path.Join(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
337+
ctx.Data["Username"] = ctx.Repo.Owner.Name
338+
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
332339
} else {
333340
prInfo := PrepareViewPullInfo(ctx, issue)
334341
if ctx.Written() {
@@ -356,6 +363,10 @@ func ViewPullFiles(ctx *context.Context) {
356363
startCommitID = prInfo.MergeBase
357364
endCommitID = headCommitID
358365
gitRepo = headGitRepo
366+
367+
headTarget = path.Join(pull.HeadUserName, pull.HeadRepo.Name)
368+
ctx.Data["Username"] = pull.HeadUserName
369+
ctx.Data["Reponame"] = pull.HeadRepo.Name
359370
}
360371

361372
diff, err := models.GetDiffRange(diffRepoPath,
@@ -374,9 +385,6 @@ func ViewPullFiles(ctx *context.Context) {
374385
return
375386
}
376387

377-
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
378-
ctx.Data["Username"] = pull.HeadUserName
379-
ctx.Data["Reponame"] = pull.HeadRepo.Name
380388
ctx.Data["IsImageFile"] = commit.IsImageFile
381389
ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", endCommitID)
382390
ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", startCommitID)

0 commit comments

Comments
 (0)