mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2025-06-01 04:12:10 +00:00
Move unit into models/unit/ (#17576)
* Move unit into models/unit/ * Rename unit.UnitType as unit.Type
This commit is contained in:
parent
b6b1e71665
commit
99b2858e62
68 changed files with 556 additions and 491 deletions
|
@ -10,6 +10,7 @@ import (
|
|||
"path"
|
||||
|
||||
"code.gitea.io/gitea/models/db"
|
||||
"code.gitea.io/gitea/models/unit"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/storage"
|
||||
"code.gitea.io/gitea/modules/timeutil"
|
||||
|
@ -62,25 +63,25 @@ func (a *Attachment) DownloadURL() string {
|
|||
}
|
||||
|
||||
// LinkedRepository returns the linked repo if any
|
||||
func (a *Attachment) LinkedRepository() (*Repository, UnitType, error) {
|
||||
func (a *Attachment) LinkedRepository() (*Repository, unit.Type, error) {
|
||||
if a.IssueID != 0 {
|
||||
iss, err := GetIssueByID(a.IssueID)
|
||||
if err != nil {
|
||||
return nil, UnitTypeIssues, err
|
||||
return nil, unit.TypeIssues, err
|
||||
}
|
||||
repo, err := GetRepositoryByID(iss.RepoID)
|
||||
unitType := UnitTypeIssues
|
||||
unitType := unit.TypeIssues
|
||||
if iss.IsPull {
|
||||
unitType = UnitTypePullRequests
|
||||
unitType = unit.TypePullRequests
|
||||
}
|
||||
return repo, unitType, err
|
||||
} else if a.ReleaseID != 0 {
|
||||
rel, err := GetReleaseByID(a.ReleaseID)
|
||||
if err != nil {
|
||||
return nil, UnitTypeReleases, err
|
||||
return nil, unit.TypeReleases, err
|
||||
}
|
||||
repo, err := GetRepositoryByID(rel.RepoID)
|
||||
return repo, UnitTypeReleases, err
|
||||
return repo, unit.TypeReleases, err
|
||||
}
|
||||
return nil, -1, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue