|
|
@ -68,7 +68,7 @@ func (label *Label) APIFormat() *api.Label { |
|
|
|
return &api.Label{ |
|
|
|
return &api.Label{ |
|
|
|
ID: label.ID, |
|
|
|
ID: label.ID, |
|
|
|
Name: label.Name, |
|
|
|
Name: label.Name, |
|
|
|
Color: label.Color, |
|
|
|
Color: strings.TrimLeft(label.Color, "#"), |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -103,7 +103,28 @@ func NewLabels(labels ...*Label) error { |
|
|
|
return err |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// getLabelOfRepoByID returns a label by ID in given repository.
|
|
|
|
// getLabelOfRepoByName returns a label by Name in given repository.
|
|
|
|
|
|
|
|
// If pass repoID as 0, then ORM will ignore limitation of repository
|
|
|
|
|
|
|
|
// and can return arbitrary label with any valid ID.
|
|
|
|
|
|
|
|
func getLabelOfRepoByName(e Engine, repoID int64, labelName string) (*Label, error) { |
|
|
|
|
|
|
|
if len(labelName) <= 0 { |
|
|
|
|
|
|
|
return nil, ErrLabelNotExist{0, repoID} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
l := &Label{ |
|
|
|
|
|
|
|
Name: labelName, |
|
|
|
|
|
|
|
RepoID: repoID, |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
has, err := x.Get(l) |
|
|
|
|
|
|
|
if err != nil { |
|
|
|
|
|
|
|
return nil, err |
|
|
|
|
|
|
|
} else if !has { |
|
|
|
|
|
|
|
return nil, ErrLabelNotExist{0, l.RepoID} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return l, nil |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// getLabelInRepoByID returns a label by ID in given repository.
|
|
|
|
// If pass repoID as 0, then ORM will ignore limitation of repository
|
|
|
|
// If pass repoID as 0, then ORM will ignore limitation of repository
|
|
|
|
// and can return arbitrary label with any valid ID.
|
|
|
|
// and can return arbitrary label with any valid ID.
|
|
|
|
func getLabelOfRepoByID(e Engine, repoID, labelID int64) (*Label, error) { |
|
|
|
func getLabelOfRepoByID(e Engine, repoID, labelID int64) (*Label, error) { |
|
|
@ -134,6 +155,11 @@ func GetLabelOfRepoByID(repoID, labelID int64) (*Label, error) { |
|
|
|
return getLabelOfRepoByID(x, repoID, labelID) |
|
|
|
return getLabelOfRepoByID(x, repoID, labelID) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// GetLabelOfRepoByName returns a label by name in given repository.
|
|
|
|
|
|
|
|
func GetLabelOfRepoByName(repoID int64, labelName string) (*Label, error) { |
|
|
|
|
|
|
|
return getLabelOfRepoByName(x, repoID, labelName) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// GetLabelsInRepoByIDs returns a list of labels by IDs in given repository,
|
|
|
|
// GetLabelsInRepoByIDs returns a list of labels by IDs in given repository,
|
|
|
|
// it silently ignores label IDs that are not belong to the repository.
|
|
|
|
// it silently ignores label IDs that are not belong to the repository.
|
|
|
|
func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error) { |
|
|
|
func GetLabelsInRepoByIDs(repoID int64, labelIDs []int64) ([]*Label, error) { |
|
|
|