mirror of
https://github.com/gogs/gogs.git
synced 2025-05-31 11:42:13 +00:00
repo/pull: handle head repository of merged pull requests deleted
This commit is contained in:
parent
a534f9f9b6
commit
8fa6d0d302
@ -616,9 +616,7 @@ func runWeb(ctx *cli.Context) error {
|
||||
}, ignSignIn, context.RepoAssignment(), context.RepoRef())
|
||||
|
||||
m.Group("/:username", func() {
|
||||
m.Group("", func() {
|
||||
m.Get("/:reponame", repo.Home)
|
||||
}, ignSignIn, context.RepoAssignment(true), context.RepoRef())
|
||||
m.Get("/:reponame", ignSignIn, context.RepoAssignment(true), context.RepoRef(), repo.Home)
|
||||
|
||||
m.Group("/:reponame", func() {
|
||||
m.Head("/tasks/trigger", repo.TriggerTask)
|
||||
|
File diff suppressed because one or more lines are too long
@ -242,8 +242,11 @@ func ViewPullCommits(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
pull := issue.PullRequest
|
||||
ctx.Data["Username"] = pull.HeadUserName
|
||||
ctx.Data["Reponame"] = pull.HeadRepo.Name
|
||||
|
||||
if pull.HeadRepo != nil {
|
||||
ctx.Data["Username"] = pull.HeadUserName
|
||||
ctx.Data["Reponame"] = pull.HeadRepo.Name
|
||||
}
|
||||
|
||||
var commits *list.List
|
||||
if pull.HasMerged {
|
||||
@ -362,16 +365,21 @@ func ViewPullFiles(ctx *context.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
|
||||
ctx.Data["IsSplitStyle"] = ctx.Query("style") == "split"
|
||||
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)
|
||||
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "raw", endCommitID)
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
|
||||
// It is possible head repo has been deleted for merged pull requests
|
||||
if pull.HeadRepo != nil {
|
||||
ctx.Data["Username"] = pull.HeadUserName
|
||||
ctx.Data["Reponame"] = pull.HeadRepo.Name
|
||||
|
||||
headTarget := path.Join(pull.HeadUserName, pull.HeadRepo.Name)
|
||||
ctx.Data["SourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", endCommitID)
|
||||
ctx.Data["BeforeSourcePath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "src", startCommitID)
|
||||
ctx.Data["RawPath"] = setting.AppSubUrl + "/" + path.Join(headTarget, "raw", endCommitID)
|
||||
}
|
||||
|
||||
ctx.Data["RequireHighlightJS"] = true
|
||||
ctx.HTML(200, PULL_FILES)
|
||||
}
|
||||
|
||||
@ -387,11 +395,7 @@ func MergePullRequest(ctx *context.Context) {
|
||||
|
||||
pr, err := models.GetPullRequestByIssueID(issue.ID)
|
||||
if err != nil {
|
||||
if models.IsErrPullRequestNotExist(err) {
|
||||
ctx.Handle(404, "GetPullRequestByIssueID", nil)
|
||||
} else {
|
||||
ctx.Handle(500, "GetPullRequestByIssueID", err)
|
||||
}
|
||||
ctx.NotFoundOrServerError("GetPullRequestByIssueID", models.IsErrPullRequestNotExist, err)
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -41,7 +41,12 @@
|
||||
</td>
|
||||
|
||||
<td class="message collapsing has-emoji">
|
||||
<a rel="nofollow" class="ui sha label" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSha .ID.String}}</a>
|
||||
{{/* Username or Reponame doesn't present we assume the source repository no longer exists */}}
|
||||
{{if not (and $.Username $.Reponame)}}
|
||||
<span class="ui sha label">{{ShortSha .ID.String}}</span>
|
||||
{{else}}
|
||||
<a rel="nofollow" class="ui sha label" href="{{AppSubUrl}}/{{$.Username}}/{{$.Reponame}}/commit/{{.ID}}">{{ShortSha .ID.String}}</a>
|
||||
{{end}}
|
||||
<span {{if gt .ParentCount 1}}class="grey text"{{end}}>{{RenderCommitMessage false .Summary $.RepoLink $.Repository.ComposeMetas}}</span>
|
||||
</td>
|
||||
<td class="grey text right aligned">{{TimeSince .Author.When $.Lang}}</td>
|
||||
|
@ -71,7 +71,7 @@
|
||||
<div class="ui right">
|
||||
{{if $file.IsDeleted}}
|
||||
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.BeforeSourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{else}}
|
||||
{{else if $.SourcePath}} {{/* No SourcePath we assume the source repository no longer exists */}}
|
||||
<a class="ui basic grey tiny button" rel="nofollow" href="{{EscapePound $.SourcePath}}/{{EscapePound .Name}}">{{$.i18n.Tr "repo.diff.view_file"}}</a>
|
||||
{{end}}
|
||||
</div>
|
||||
|
@ -64,8 +64,8 @@
|
||||
<a href="{{$.RepoLink}}/src/{{.TagName}}" rel="nofollow"><i class="tag icon"></i> {{.TagName}}</a>
|
||||
</h4>
|
||||
<div class="download">
|
||||
<a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i> ZIP</a>
|
||||
<a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><i class="octicon octicon-file-zip"></i> TAR.GZ</a>
|
||||
<a href="{{$.RepoLink}}/archive/{{.TagName}}.zip" rel="nofollow"><i class="octicon octicon-file-zip"></i>ZIP</a>
|
||||
<a href="{{$.RepoLink}}/archive/{{.TagName}}.tar.gz"><i class="octicon octicon-file-zip"></i>TAR.GZ</a>
|
||||
</div>
|
||||
{{end}}
|
||||
<span class="dot"> </span>
|
||||
|
Loading…
x
Reference in New Issue
Block a user