Unverified Commit 183a80bb authored by Sander van Harmelen's avatar Sander van Harmelen Committed by GitHub

Support the Gitlab inconsistency around label names (#490)

parent 4d479a6b
......@@ -17,6 +17,7 @@
package gitlab
import (
"encoding/json"
"fmt"
"net/url"
)
......@@ -44,6 +45,26 @@ type Label struct {
Priority int `json:"priority"`
}
// UnmarshalJSON implements the json.Unmarshaler interface.
func (l *Label) UnmarshalJSON(data []byte) error {
type alias Label
if err := json.Unmarshal(data, (*alias)(l)); err != nil {
return err
}
if l.Name == "" {
var raw map[string]interface{}
if err := json.Unmarshal(data, &raw); err != nil {
return err
}
if title, ok := raw["title"].(string); ok {
l.Name = title
}
}
return nil
}
func (l Label) String() string {
return Stringify(l)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment