mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-05-31 20:02:09 +00:00
refactor some functions to support ctx as first parameter (#21878)
Co-authored-by: KN4CK3R <admin@oldschoolhack.me> Co-authored-by: Lauris BH <lauris@nix.lv>
This commit is contained in:
parent
8698458f48
commit
0a7d3ff786
145 changed files with 360 additions and 369 deletions
|
@ -103,24 +103,24 @@ func UpdateRepository(repo *repo_model.Repository, visibilityChanged bool) (err
|
|||
}
|
||||
|
||||
// LinkedRepository returns the linked repo if any
|
||||
func LinkedRepository(a *repo_model.Attachment) (*repo_model.Repository, unit.Type, error) {
|
||||
func LinkedRepository(ctx context.Context, a *repo_model.Attachment) (*repo_model.Repository, unit.Type, error) {
|
||||
if a.IssueID != 0 {
|
||||
iss, err := issues_model.GetIssueByID(db.DefaultContext, a.IssueID)
|
||||
iss, err := issues_model.GetIssueByID(ctx, a.IssueID)
|
||||
if err != nil {
|
||||
return nil, unit.TypeIssues, err
|
||||
}
|
||||
repo, err := repo_model.GetRepositoryByID(iss.RepoID)
|
||||
repo, err := repo_model.GetRepositoryByID(ctx, iss.RepoID)
|
||||
unitType := unit.TypeIssues
|
||||
if iss.IsPull {
|
||||
unitType = unit.TypePullRequests
|
||||
}
|
||||
return repo, unitType, err
|
||||
} else if a.ReleaseID != 0 {
|
||||
rel, err := repo_model.GetReleaseByID(db.DefaultContext, a.ReleaseID)
|
||||
rel, err := repo_model.GetReleaseByID(ctx, a.ReleaseID)
|
||||
if err != nil {
|
||||
return nil, unit.TypeReleases, err
|
||||
}
|
||||
repo, err := repo_model.GetRepositoryByID(rel.RepoID)
|
||||
repo, err := repo_model.GetRepositoryByID(ctx, rel.RepoID)
|
||||
return repo, unit.TypeReleases, err
|
||||
}
|
||||
return nil, -1, nil
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue