Skip to content

Conversation

@JakobDev
Copy link
Contributor

@JakobDev JakobDev commented Jun 2, 2023

The events in the Comment history have now Links. e.g. If foo added this to the bar milestone, appears in the Comments, bar is now a Link to the bar Milestone. On the UI Side nothing changed. Everything looks the same.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Jun 2, 2023
Comment on lines +1558 to +1571
if comment.Milestone != nil && comment.Milestone.ID != -1 {
err = comment.Milestone.LoadRepo(ctx)
if err != nil {
ctx.ServerError("LoadMilestoneRepo", err)
return
}
}
if comment.OldMilestone != nil && comment.OldMilestone.ID != -1 {
err = comment.OldMilestone.LoadRepo(ctx)
if err != nil {
ctx.ServerError("LoadMilestoneRepo", err)
return
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend two separate methods Comment#LoadMilestone and Comment#LoadOldMilestone


// Link returns the milestone Link
func (m *Milestone) Link() string {
return fmt.Sprintf("%s/milestone/%d", m.Repo.HTMLURL(), m.ID)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You want m.Repo.Link here.
HTMLURL is absolute while Link should be relative.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
return fmt.Sprintf("%s/milestone/%d", m.Repo.HTMLURL(), m.ID)
return fmt.Sprintf("%s/milestone/%d", m.Repo.Link(), m.ID)
{{$.locale.Tr "repo.issues.remove_self_assignment" $createdStr | Safe}}
{{else}}
{{$.locale.Tr "repo.issues.remove_assignee_at" (.Poster.GetDisplayName|Escape) $createdStr | Safe}}
{{$.locale.Tr "repo.issues.remove_assignee_at" (printf `<a href="%s">%s</a>` .Poster.HomeLink (.Poster.GetDisplayName|Escape)) $createdStr | Safe}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are adding the same exact call that many times that we should perhaps extract it into a separate function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only used in this template. Do we really need a own function for for every object something that is used in a single template a few times?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging.

4 participants