Skip to content

Commit e7ff3be

Browse files
committed
fix bug when get pull request and ref original author on code comments
1 parent 9824001 commit e7ff3be

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

modules/migrations/gitea.go

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -774,7 +774,8 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
774774
// get pr
775775
pr, ok := g.prCache[issueID]
776776
if !ok {
777-
pr, err := models.GetPullRequestByID(issueID)
777+
var err error
778+
pr, err = models.GetPullRequestByIssueID(issueID)
778779
if err != nil {
779780
return err
780781
}
@@ -794,14 +795,16 @@ func (g *GiteaLocalUploader) CreateReviews(reviews ...*base.Review) error {
794795
patch := gitdiff.CutDiffAroundLine(patchBuf, int64((&models.Comment{Line: line}).UnsignedLine()), line < 0, setting.UI.CodeCommentLines)
795796

796797
var c = models.Comment{
797-
Type: models.CommentTypeCode,
798-
PosterID: comment.PosterID,
799-
IssueID: issueID,
800-
Content: comment.Content,
801-
Line: line,
802-
TreePath: comment.TreePath,
803-
CommitSHA: comment.CommitID,
804-
Patch: patch,
798+
Type: models.CommentTypeCode,
799+
PosterID: comment.PosterID,
800+
IssueID: issueID,
801+
Content: comment.Content,
802+
Line: line,
803+
TreePath: comment.TreePath,
804+
CommitSHA: comment.CommitID,
805+
Patch: patch,
806+
CreatedUnix: timeutil.TimeStamp(comment.CreatedAt.Unix()),
807+
UpdatedUnix: timeutil.TimeStamp(comment.UpdatedAt.Unix()),
805808
}
806809

807810
if userid > 0 {

templates/repo/diff/comments.tmpl

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,22 @@
22

33
{{ $createdStr:= TimeSinceUnix .CreatedUnix $.root.Lang }}
44
<div class="comment" id="{{.HashTag}}">
5-
<a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>
6-
<img src="{{.Poster.RelAvatarLink}}">
7-
</a>
5+
{{if .OriginalAuthor }}
6+
<span class="avatar"><img src="/img/avatar_default.png"></span>
7+
{{else}}
8+
<a class="avatar" {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>
9+
<img src="{{.Poster.RelAvatarLink}}">
10+
</a>
11+
{{end}}
812
<div class="content">
913
<div class="ui top attached header">
10-
<span class="text grey"><a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a> {{$.root.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span>
14+
<span class="text grey">
15+
{{if .OriginalAuthor }}
16+
<span class="text black"><i class="fa {{MigrationIcon $.root.Repository.GetOriginalURLHostname}}" aria-hidden="true"></i> {{ .OriginalAuthor }}</span><span class="text grey"> {{$.root.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}</span> <span class="text migrate">{{if $.root.Repository.OriginalURL}} ({{$.root.i18n.Tr "repo.migrated_from" $.root.Repository.OriginalURL $.root.Repository.GetOriginalURLHostname | Safe }}){{end}}</span>
17+
{{else}}
18+
<a {{if gt .Poster.ID 0}}href="{{.Poster.HomeLink}}"{{end}}>{{.Poster.GetDisplayName}}</a> {{$.root.i18n.Tr "repo.issues.commented_at" .HashTag $createdStr | Safe}}
19+
{{end}}
20+
</span>
1121
<div class="ui right actions">
1222
{{if and .Review}}
1323
{{if eq .Review.Type 0}}

0 commit comments

Comments
 (0)