grim/youtrack-import

Parents 45baf35db295
Children ff8d512f4f72
Split the version field into AffectedVersion and FixVersion while having trac and bitbucket use AffectedVersion. Also put the trac milestone into the Fix Version.
--- a/bitbucket/converter.go Tue Aug 04 22:19:35 2020 -0500
+++ b/bitbucket/converter.go Tue Aug 11 22:10:48 2020 -0500
@@ -70,11 +70,11 @@
Reporter: reporter,
Assignee: assignee,
- Priority: bb.Priority,
- Type: bb.Kind,
- State: bb.Status,
- Version: bb.Version,
- Subsystem: bb.Component,
+ Priority: bb.Priority,
+ Type: bb.Kind,
+ State: bb.Status,
+ AffectedVersion: bb.Version,
+ Subsystem: bb.Component,
Markdown: true,
--- a/trac/tickets.go Tue Aug 04 22:19:35 2020 -0500
+++ b/trac/tickets.go Tue Aug 11 22:10:48 2020 -0500
@@ -178,19 +178,20 @@
}
issue := &youtrack.Issue{
- Number: t.ID,
- Summary: t.Summary,
- Description: convertComment(t.Description),
- Created: convertTime(t.Time),
- Updated: convertTime(t.ChangeTime),
- Reporter: convertUsername(t.Reporter),
- Assignee: convertUsername(t.Owner),
- Markdown: true,
- Version: convertString(t.Version),
- Subsystem: convertString(t.Component),
- Priority: priorityMap[convertString(t.Priority)],
- Type: typeMap[t.Type],
- State: stateMap[t.Status],
+ Number: t.ID,
+ Summary: t.Summary,
+ Description: convertComment(t.Description),
+ Created: convertTime(t.Time),
+ Updated: convertTime(t.ChangeTime),
+ Reporter: convertUsername(t.Reporter),
+ Assignee: convertUsername(t.Owner),
+ Markdown: true,
+ AffectedVersion: convertString(t.Version),
+ FixVersion: convertString(t.Milestone),
+ Subsystem: convertString(t.Component),
+ Priority: priorityMap[convertString(t.Priority)],
+ Type: typeMap[t.Type],
+ State: stateMap[t.Status],
}
// There are some instances were reporters are null in our trac database, so
--- a/trac/versions.go Tue Aug 04 22:19:35 2020 -0500
+++ b/trac/versions.go Tue Aug 11 22:10:48 2020 -0500
@@ -14,9 +14,23 @@
func (e *environment) loadVersions() ([]youtrack.Version, error) {
versions := []version{}
+ // we grab both the versions and the milestones as milestones are
+ // essentially treated as the fix version in trac.
err := e.db.Select(
&versions,
- "SELECT * from version ORDER BY name DESC",
+ `SELECT
+ a.name, a.time, a.description
+ FROM
+ trac_pidgin.version a
+ UNION ALL
+ SELECT
+ b.name, b.due as time, b.description
+ FROM
+ trac_pidgin.milestone b
+ WHERE NOT EXISTS
+ (SELECT NULL FROM trac_pidgin.version c WHERE c.name = b.name)
+ ORDER BY
+ name`,
)
ytVersions := make([]youtrack.Version, len(versions))
--- a/youtrack/issue.go Tue Aug 04 22:19:35 2020 -0500
+++ b/youtrack/issue.go Tue Aug 11 22:10:48 2020 -0500
@@ -9,21 +9,22 @@
)
type Issue struct {
- Number int
- Summary string
- Description string
- Created time.Time
- Updated time.Time
- UpdatedBy string
- Resolved time.Time
- Reporter string
- Assignee string
- Voters []string
- Watchers []string
- PermittedGroup string
- Markdown bool
- Version string
- Subsystem string
+ Number int
+ Summary string
+ Description string
+ Created time.Time
+ Updated time.Time
+ UpdatedBy string
+ Resolved time.Time
+ Reporter string
+ Assignee string
+ Voters []string
+ Watchers []string
+ PermittedGroup string
+ Markdown bool
+ AffectedVersion string
+ FixVersion string
+ Subsystem string
Priority string
Type string
@@ -109,8 +110,12 @@
x.AddField("permittedGroup", i.PermittedGroup)
}
- if i.Version != "" {
- x.AddField("Fix Versions", i.Version)
+ if i.AffectedVersion != "" {
+ x.AddField("Affected Versions", i.AffectedVersion)
+ }
+
+ if i.FixVersion != "" {
+ x.AddField("Fix Versions", i.FixVersion)
}
if i.Subsystem != "" {