grim/youtrack-import
Clone
Summary
Browse
Changes
Graph
Use the built in mime stuff to figure out the content type for attachments
2020-01-14, Gary Kramlich
4763018b25c8
Use the built in mime stuff to figure out the content type for attachments
package
youtrack
import
(
"fmt"
"strings"
"hg.sr.ht/~grim/youtrack-import/globals"
)
func
Import
(
g
*
globals
.
Globals
,
p
*
Project
)
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
}
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 subsystems
if
err
:=
client
.
CreateSubsystems
(
p
);
err
!=
nil
{
return
err
}
// create the versions
if
err
:=
client
.
CreateVersions
(
p
);
err
!=
nil
{
return
err
}
// create the users
if
err
:=
client
.
ImportUsers
(
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
}