grim/youtrack-import
Clone
Summary
Browse
Changes
Graph
Split the version field into AffectedVersion and FixVersion while having trac and bitbucket use AffectedVersion. Also put the trac milestone into the Fix Version.
draft
2020-08-11, Gary Kramlich
faf8f5a4120f
Split the version field into AffectedVersion and FixVersion while having trac and bitbucket use AffectedVersion. Also put the trac milestone into the Fix 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
}