Skip to content

Commit 245089b

Browse files
authored
Prevent server 500 on compare branches with no common history (#6555) (#6558)
* Prevent server 500 on compare branches with no common history (#6555) * Update code.gitea.io/git module
1 parent 2551660 commit 245089b

File tree

6 files changed

+41
-19
lines changed

6 files changed

+41
-19
lines changed

Gopkg.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

options/locale/locale_en-US.ini

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -683,6 +683,7 @@ editor.cannot_commit_to_protected_branch = Cannot commit to protected branch '%s
683683
684684
commits.desc = Browse source code change history.
685685
commits.commits = Commits
686+
commits.no_commits = No commits in common. '%s' and '%s' have entirely different histories.
686687
commits.search = Search commits…
687688
commits.find = Search
688689
commits.search_all = All Branches

templates/repo/commits_table.tmpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
<h4 class="ui top attached header">
22
<div class="ui stackable grid">
3-
<div class="six wide column">
4-
{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}} {{if .Branch}}({{.Branch}}){{end}}
3+
<div class="ten wide column">
4+
{{if or .PageIsCommits (gt .CommitCount 0)}}
5+
{{.CommitCount}} {{.i18n.Tr "repo.commits.commits"}} {{if .Branch}}({{.Branch}}){{end}}
6+
{{else}}
7+
{{.i18n.Tr "repo.commits.no_commits" $.BaseBranch $.HeadBranch }} {{if .Branch}}({{.Branch}}){{end}}
8+
{{end}}
59
</div>
6-
<div class="ten wide right aligned column">
10+
<div class="six wide right aligned column">
711
{{if .PageIsCommits}}
812
<form class="ignore-dirty" action="{{.RepoLink}}/commits/{{.BranchNameSubURL | EscapePound}}/search">
913
<div class="ui tiny search input">
@@ -23,7 +27,7 @@
2327
</div>
2428
</h4>
2529

26-
{{if .Commits}}
30+
{{if and .Commits (gt .CommitCount 0)}}
2731
<div class="ui attached table segment">
2832
<table class="ui very basic striped fixed table single line" id="commits-table">
2933
<thead>

templates/repo/pulls/compare.tmpl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@
5454
<div class="ui segment">
5555
{{.i18n.Tr "repo.pulls.has_pull_request" $.RepoLink $.RepoRelPath .PullRequest.Index | Safe}}
5656
</div>
57+
{{else if eq .CommitCount 0 }}
58+
{{template "repo/commits_table" .}}
59+
{{template "repo/diff/box" .}}
5760
{{else}}
5861
{{template "repo/issue/new_form" .}}
5962
{{template "repo/commits_table" .}}

vendor/code.gitea.io/git/hook.go

Lines changed: 11 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/code.gitea.io/git/repo_pull.go

Lines changed: 16 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)