Skip to content

Commit 23414ac

Browse files
gzsomborlafriks
authored andcommitted
Fix panic: template: repo/issue/list:210: unexpected "=" in operand (#6041)
1 parent 7f38e2d commit 23414ac

File tree

2 files changed

+21
-17
lines changed

2 files changed

+21
-17
lines changed

models/issue.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -953,6 +953,25 @@ func (issue *Issue) GetTasksDone() int {
953953
return len(issueTasksDonePat.FindAllStringIndex(issue.Content, -1))
954954
}
955955

956+
// GetLastEventTimestamp returns the last user visible event timestamp, either the creation of this issue or the close.
957+
func (issue *Issue) GetLastEventTimestamp() util.TimeStamp {
958+
if issue.IsClosed {
959+
return issue.ClosedUnix
960+
}
961+
return issue.CreatedUnix
962+
}
963+
964+
// GetLastEventLabel returns the localization label for the current issue.
965+
func (issue *Issue) GetLastEventLabel() string {
966+
if issue.IsClosed {
967+
if issue.IsPull && issue.PullRequest.HasMerged {
968+
return "repo.pulls.merged_by"
969+
}
970+
return "repo.issues.closed_by"
971+
}
972+
return "repo.issues.opened_by"
973+
}
974+
956975
// NewIssueOptions represents the options of a new issue.
957976
type NewIssueOptions struct {
958977
Repo *Repository

templates/repo/issue/list.tmpl

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@
181181

182182
<div class="issue list">
183183
{{range .Issues}}
184-
{{ $timeStr:= TimeSinceUnix .CreatedUnix $.Lang }}
185184
<li class="item">
186185
<div class="ui checkbox issue-checkbox">
187186
<input type="checkbox" data-issue-id={{.ID}}></input>
@@ -205,22 +204,8 @@
205204
{{end}}
206205

207206
<p class="desc">
208-
{{ $textToTranslate := "repo.issues.opened_by" }}
209-
{{ if not .IsClosed }}
210-
{{ $timeStr = TimeSinceUnix .CreatedUnix $.Lang }}
211-
{{ else if and .IsClosed .IsPull }}
212-
{{ $timeStr = TimeSinceUnix .ClosedUnix $.Lang }}
213-
{{ if .PullRequest.HasMerged }}
214-
{{ $textToTranslate = "repo.pulls.merged_by"}}
215-
{{ else }}
216-
{{ $textToTranslate = "repo.issues.closed_by"}}
217-
{{ end }}
218-
{{ else }}
219-
{{ $timeStr = TimeSinceUnix .ClosedUnix $.Lang }}
220-
{{ $textToTranslate = "repo.issues.closed_by"}}
221-
{{ end }}
222-
223-
{{$.i18n.Tr $textToTranslate $timeStr .Poster.HomeLink .Poster.Name | Safe}}
207+
{{ $timeStr := TimeSinceUnix .GetLastEventTimestamp $.Lang }}
208+
{{$.i18n.Tr .GetLastEventLabel $timeStr .Poster.HomeLink .Poster.Name | Safe}}
224209

225210
{{$tasks := .GetTasks}}
226211
{{if gt $tasks 0}}

0 commit comments

Comments
 (0)