grim/youtrack-import

cdadae07e61c
Convert bold, italic, and bold italic to the markdown version
package youtrack
import (
"fmt"
)
func (c *Client) GetProjectSubsystems(projectID string) (*OwnedFieldBundle, error) {
pcf, err := c.GetProjectCustomField(projectID, "Subsystem")
if err != nil {
return nil, err
}
name, err := pcf.GetBundleName()
if err != nil {
return nil, err
}
return c.GetOwnedFieldBundle(name)
}
func (c *Client) CreateSubsystems(p *Project) error {
bundle, err := c.GetProjectSubsystems(p.ID)
if err != nil {
return err
}
// create a map of the existing subsystems
existing := map[string]bool{}
for _, field := range bundle.Fields {
existing[field.Value] = true
}
// now run through the map and add the new values
for _, subsystem := range p.Subsystems {
fmt.Printf("creating subsystem %q ... ", subsystem.Value)
if _, found := existing[subsystem.Value]; found {
fmt.Printf("already exists.\n")
continue
}
if err := c.AppendOwnedFieldBundle(bundle.Name, subsystem); err != nil {
fmt.Printf("failed.\n")
return err
}
fmt.Printf("done.\n")
}
return nil
}