-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Fix empty project displayed in issue sidebar #25802
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
ccce338
50b9574
e76a717
6c4eef4
901d374
0168d6b
ec6000e
6d3529b
632f284
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -16,13 +16,14 @@ import ( | |||||||
func (issue *Issue) LoadProject(ctx context.Context) (err error) { | ||||||||
if issue.Project == nil { | ||||||||
var p project_model.Project | ||||||||
if _, err = db.GetEngine(ctx).Table("project"). | ||||||||
has, err := db.GetEngine(ctx).Table("project"). | ||||||||
Join("INNER", "project_issue", "project.id=project_issue.project_id"). | ||||||||
Where("project_issue.issue_id = ?", issue.ID). | ||||||||
Get(&p); err != nil { | ||||||||
Where("project_issue.issue_id = ?", issue.ID).Get(&p) | ||||||||
if err != nil { | ||||||||
return err | ||||||||
} else if has { | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Not a blocker. But these are two different checks There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They look the same to me. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Technically you are 💯 correct. From the readability point of view PS: No blocker my side. Just a thought. :) |
||||||||
issue.Project = &p | ||||||||
} | ||||||||
issue.Project = &p | ||||||||
} | ||||||||
return err | ||||||||
} | ||||||||
|
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has
is almost idiomatic within the gitea coderes
is not what's returned here: The function returnsbool, err
, not<any>, err
to show whether the pointer got a new value (see 3.)&p
means that the variablep
is changed directly.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only potential alternative to
has
that would make sense and is also used throughout the code isexists
which is probably a better name for it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh okay, didn't know that it is used in Gitea 😆