MCPcopy Create free account
hub / github.com/gogs/gogs / getLabelOfRepoByID

Function getLabelOfRepoByID

internal/database/issue_label.go:147–163  ·  view source on GitHub ↗

getLabelInRepoByID returns a label by ID in given repository. If pass repoID as 0, then ORM will ignore limitation of repository and can return arbitrary label with any valid ID.

(e Engine, repoID, labelID int64)

Source from the content-addressed store, hash-verified

145// If pass repoID as 0, then ORM will ignore limitation of repository
146// and can return arbitrary label with any valid ID.
147func getLabelOfRepoByID(e Engine, repoID, labelID int64) (*Label, error) {
148 if labelID <= 0 {
149 return nil, ErrLabelNotExist{args: map[string]any{"repoID": repoID, "labelID": labelID}}
150 }
151
152 l := &Label{
153 ID: labelID,
154 RepoID: repoID,
155 }
156 has, err := e.Get(l)
157 if err != nil {
158 return nil, err
159 } else if !has {
160 return nil, ErrLabelNotExist{args: map[string]any{"repoID": repoID, "labelID": labelID}}
161 }
162 return l, nil
163}
164
165// GetLabelByID returns a label by given ID.
166func GetLabelByID(id int64) (*Label, error) {

Callers 2

GetLabelByIDFunction · 0.85
GetLabelOfRepoByIDFunction · 0.85

Calls 1

GetMethod · 0.65

Tested by

no test coverage detected