(c *context.Context, issue *database.Issue)
| 200 | } |
| 201 | |
| 202 | func PrepareViewPullInfo(c *context.Context, issue *database.Issue) *gitutil.PullRequestMeta { |
| 203 | repo := c.Repo.Repository |
| 204 | pull := issue.PullRequest |
| 205 | |
| 206 | c.Data["HeadTarget"] = pull.HeadUserName + "/" + pull.HeadBranch |
| 207 | c.Data["BaseTarget"] = c.Repo.Owner.Name + "/" + pull.BaseBranch |
| 208 | |
| 209 | var ( |
| 210 | headGitRepo *git.Repository |
| 211 | err error |
| 212 | ) |
| 213 | |
| 214 | if pull.HeadRepo != nil { |
| 215 | headGitRepo, err = git.Open(pull.HeadRepo.RepoPath()) |
| 216 | if err != nil { |
| 217 | c.Error(err, "open repository") |
| 218 | return nil |
| 219 | } |
| 220 | } |
| 221 | |
| 222 | if pull.HeadRepo == nil || !headGitRepo.HasBranch(pull.HeadBranch) { |
| 223 | c.Data["IsPullReuqestBroken"] = true |
| 224 | c.Data["HeadTarget"] = "deleted" |
| 225 | c.Data["NumCommits"] = 0 |
| 226 | c.Data["NumFiles"] = 0 |
| 227 | return nil |
| 228 | } |
| 229 | |
| 230 | baseRepoPath := database.RepoPath(repo.Owner.Name, repo.Name) |
| 231 | prMeta, err := gitutil.Module.PullRequestMeta(headGitRepo.Path(), baseRepoPath, pull.HeadBranch, pull.BaseBranch) |
| 232 | if err != nil { |
| 233 | if strings.Contains(err.Error(), "fatal: Not a valid object name") { |
| 234 | c.Data["IsPullReuqestBroken"] = true |
| 235 | c.Data["BaseTarget"] = "deleted" |
| 236 | c.Data["NumCommits"] = 0 |
| 237 | c.Data["NumFiles"] = 0 |
| 238 | return nil |
| 239 | } |
| 240 | |
| 241 | c.Error(err, "get pull request meta") |
| 242 | return nil |
| 243 | } |
| 244 | c.Data["NumCommits"] = len(prMeta.Commits) |
| 245 | c.Data["NumFiles"] = prMeta.NumFiles |
| 246 | return prMeta |
| 247 | } |
| 248 | |
| 249 | func ViewPullCommits(c *context.Context) { |
| 250 | c.Data["PageIsPullList"] = true |
no test coverage detected