-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
project_columns.go
48 lines (43 loc) · 1.02 KB
/
project_columns.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
package migrator
import (
"fmt"
"io"
"time"
"github.com/itchyny/github-migrator/github"
)
var waitProjectColumnDuration = 100 * time.Millisecond
func (m *migrator) migrateProjectColumns(sourceID, targetID int) error {
sourceColumns := m.source.ListProjectColumns(sourceID)
targetColumns, err := github.ProjectColumnsToSlice(
m.target.ListProjectColumns(targetID),
)
if err != nil {
return err
}
for {
c, err := sourceColumns.Next()
if err != nil {
if err != io.EOF {
return err
}
return nil
}
fmt.Printf("[=>] migrating a project column: %s\n", c.Name)
d := lookupProjectColumn(targetColumns, c)
if d == nil {
fmt.Printf("[>>] creating a new project column: %s\n", c.Name)
if _, err = m.target.CreateProjectColumn(targetID, c.Name); err != nil {
return err
}
}
time.Sleep(waitProjectColumnDuration)
}
}
func lookupProjectColumn(ps []*github.ProjectColumn, c *github.ProjectColumn) *github.ProjectColumn {
for _, d := range ps {
if c.Name == d.Name {
return d
}
}
return nil
}