Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix displaying commits and files of PR created from now deleted fork #2023

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 14 additions & 6 deletions routers/repo/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -256,15 +256,16 @@ func ViewPullCommits(ctx *context.Context) {
return
}
pull := issue.PullRequest
ctx.Data["Username"] = pull.HeadUserName
ctx.Data["Reponame"] = pull.HeadRepo.Name

var commits *list.List
if pull.HasMerged {
PrepareMergedViewPullInfo(ctx, issue)
if ctx.Written() {
return
}
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name

startCommit, err := ctx.Repo.GitRepo.GetCommit(pull.MergeBase)
if err != nil {
ctx.Handle(500, "Repo.GitRepo.GetCommit", err)
Expand All @@ -280,7 +281,6 @@ func ViewPullCommits(ctx *context.Context) {
ctx.Handle(500, "Repo.GitRepo.CommitsBetween", err)
return
}

} else {
prInfo := PrepareViewPullInfo(ctx, issue)
if ctx.Written() {
Expand All @@ -289,6 +289,8 @@ func ViewPullCommits(ctx *context.Context) {
ctx.Handle(404, "ViewPullCommits", nil)
return
}
ctx.Data["Username"] = pull.HeadUserName
ctx.Data["Reponame"] = pull.HeadRepo.Name
commits = prInfo.Commits
}

Expand Down Expand Up @@ -319,6 +321,7 @@ func ViewPullFiles(ctx *context.Context) {
gitRepo *git.Repository
)

var headTarget string
if pull.HasMerged {
PrepareMergedViewPullInfo(ctx, issue)
if ctx.Written() {
Expand All @@ -329,6 +332,10 @@ func ViewPullFiles(ctx *context.Context) {
startCommitID = pull.MergeBase
endCommitID = pull.MergedCommitID
gitRepo = ctx.Repo.GitRepo

headTarget = path.Join(ctx.Repo.Owner.Name, ctx.Repo.Repository.Name)
ctx.Data["Username"] = ctx.Repo.Owner.Name
ctx.Data["Reponame"] = ctx.Repo.Repository.Name
} else {
prInfo := PrepareViewPullInfo(ctx, issue)
if ctx.Written() {
Expand Down Expand Up @@ -356,6 +363,10 @@ func ViewPullFiles(ctx *context.Context) {
startCommitID = prInfo.MergeBase
endCommitID = headCommitID
gitRepo = headGitRepo

headTarget = path.Join(pull.HeadUserName, pull.HeadRepo.Name)
ctx.Data["Username"] = pull.HeadUserName
ctx.Data["Reponame"] = pull.HeadRepo.Name
}

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

headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
ctx.Data["Username"] = pull.HeadUserName
ctx.Data["Reponame"] = pull.HeadRepo.Name
ctx.Data["IsImageFile"] = commit.IsImageFile
ctx.Data["SourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", endCommitID)
ctx.Data["BeforeSourcePath"] = setting.AppSubURL + "/" + path.Join(headTarget, "src", startCommitID)
Expand Down