From 6a00d39ee151c053da9aaa903316489c8833de75 Mon Sep 17 00:00:00 2001 From: 6543 <6543@noreply.gitea.io> Date: Tue, 9 Jun 2020 07:51:37 +0000 Subject: [PATCH] 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 Reviewed-by: Andrew Thornton --- gitea/issue_label.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gitea/issue_label.go b/gitea/issue_label.go index af4b0a8..c5e560a 100644 --- a/gitea/issue_label.go +++ b/gitea/issue_label.go @@ -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