grim/youtrack-import

cdadae07e61c
Convert bold, italic, and bold italic to the markdown version
package youtrack
import (
"fmt"
"strings"
"keep.imfreedom.org/grim/youtrack-import/globals"
)
func Import(g *globals.Globals, p *Project, maxIssues int) error {
client, err := NewClient(g.URL, g.Token)
if err != nil {
return err
}
if g.ProjectID == "" {
g.ProjectID = strings.ToUpper(g.ProjectName)
}
if p.ID == "" {
p.ID = g.ProjectID
}
// now adjust the length of issues if the user has requested import a
// maximum number of issues.
if maxIssues >= 0 {
p.Issues = p.Issues[:maxIssues]
}
p.Name = g.ProjectName
p.LeadLogin = g.ProjectLeadLogin
fmt.Printf("creating project %q ... ", p.ID)
if err := client.CreateProject(p); err != nil {
fmt.Printf("failed.\n")
return err
}
fmt.Printf("done.\n")
// create the users
if err := client.ImportUsers(p); err != nil {
return err
}
// create the subsystems
if err := client.CreateSubsystems(p); err != nil {
return err
}
// create the versions
if err := client.CreateVersions(p); err != nil {
return err
}
// create the issues
if err := client.ImportIssues(p); err != nil {
return err
}
// create the attachments
if err := client.ImportAttachments(p); err != nil {
return err
}
return nil
}