grim/youtrack-import
Clone
Summary
Browse
Changes
Graph
Add support for auto linking tickets. Fixes YI-31
draft
2020-08-11, Gary Kramlich
ff8d512f4f72
Add support for auto linking tickets. Fixes YI-31
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
}