CreateLabel correct Color if needed for old versions (#365)

Merge branch 'master' into CreateLabel_correct-format-for-old-intances

CreateLabel correct Color if needed for old versions

Co-authored-by: 6543 <6543@obermui.de>
Reviewed-on: https://gitea.com/gitea/go-sdk/pulls/365
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
6543 2020-06-09 07:51:37 +00:00 committed by Andrew Thornton
parent 9be8754fec
commit 6a00d39ee1
1 changed files with 5 additions and 0 deletions

View File

@ -49,6 +49,11 @@ type CreateLabelOption struct {
// CreateLabel create one label of repository
func (c *Client) CreateLabel(owner, repo string, opt CreateLabelOption) (*Label, error) {
if len(opt.Color) == 6 {
if err := c.CheckServerVersionConstraint(">=1.12.0"); err != nil {
opt.Color = "#" + opt.Color
}
}
body, err := json.Marshal(&opt)
if err != nil {
return nil, err