grim/youtrack-import

Parents 7b898931bf51
Children 75076ea0a1ee
use a simpler approach to determining which fields need to be added so that we can maintain the order that we got them in
--- a/youtrack/subsystems.go Tue Dec 17 04:30:16 2019 -0600
+++ b/youtrack/subsystems.go Tue Dec 17 04:38:10 2019 -0600
@@ -24,22 +24,21 @@
return err
}
- // create a map of all the subsystems
- subsystems := map[string]bool{}
- for _, subsystem := range p.Subsystems {
- subsystems[subsystem] = true
- }
-
- // now remove any existing subsystems from the map
+ // create a map of the existing subsystems
+ existing := map[string]bool{}
for _, field := range bundle.Fields {
- if _, found := subsystems[field.Value]; found {
- delete(subsystems, field.Value)
- }
+ existing[field.Value] = true
}
// now run through the map and add the new values
- for subsystem, _ := range subsystems {
+ for _, subsystem := range p.Subsystems {
fmt.Printf("creating subsystem %q ... ", subsystem)
+
+ if _, found := existing[subsystem]; found {
+ fmt.Printf("already exists.\n")
+ continue
+ }
+
if err := c.AppendOwnedFieldBundle(bundle.Name, subsystem); err != nil {
fmt.Printf("failed.\n")
--- a/youtrack/version.go Tue Dec 17 04:30:16 2019 -0600
+++ b/youtrack/version.go Tue Dec 17 04:38:10 2019 -0600
@@ -80,22 +80,21 @@
return err
}
- // create a map of all the versions
- versions := map[string]bool{}
- for _, version := range p.Versions {
- versions[version] = true
+ // create a map of the existing versions
+ existing := map[string]bool{}
+ for _, version := range bundle.Versions {
+ existing[version.Name] = true
}
- // now remove any existing versions from the map
- for _, version := range bundle.Versions {
- if _, found := versions[version.Name]; found {
- delete(versions, version.Name)
+ // now run through the version slice and add all the versions
+ for _, version := range p.Versions {
+ fmt.Printf("creating version %q ... ", version)
+
+ if _, found := existing[version]; found {
+ fmt.Printf("already exists.\n")
+ continue
}
- }
- // now run through the map and add all the missing versions
- for version, _ := range versions {
- fmt.Printf("creating version %q ... ", version)
if err := c.AppendVersionFieldBundle(bundle.Name, version); err != nil {
fmt.Printf("failed.\n")