-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
71 lines (62 loc) · 2.06 KB
/
main.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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
"os"
"strconv"
"migrator/cmd"
"migrator/github"
"migrator/gitlab"
"migrator/pkg/readme"
"migrator/pkg/stats"
)
func main() {
cmd.Execute()
org := os.Getenv("GH_ORG_NAME")
projectID := os.Getenv("GL_PROJECT_ID")
intProjectID, _ := strconv.Atoi(projectID)
githubRepos, err := github.GetRepos(org)
if err != nil {
fmt.Errorf("error occured during fetching GitHub Repos, %s", err)
}
gitlabRepos, err := gitlab.GetRepos(intProjectID)
if err != nil {
fmt.Errorf("error occured during fetching GitLab Repos, %s", err)
}
t := stats.NewTable([]string{"Repo Name", "GitHub Org", "GitLab Project", "GitLab Status", "GitHub Status", "Migrated"})
for _, gitlabRepo := range gitlabRepos {
searched := false
for _, githubRepo := range githubRepos {
if githubRepo.Name == gitlabRepo.Name {
r := stats.NewRow(gitlabRepo.Name, org, projectID, true)
t.AddRow(*r)
searched = true
break
}
}
if !searched {
r := stats.NewRow(gitlabRepo.Name, org, projectID, false)
t.AddRow(*r)
}
}
readme.Update("stats.md", t.String())
// updateStatus := readme.UpdateGitHubRepoFile([]byte(t.String()), "go-action-runner", "mouismail", "stats.md")
// fmt.Printf("The migration status has been updated on Stats file successfully with status %s.", updateStatus)
fmt.Printf("The migration status has been updated on Stats file successfully")
}
//
//func compareGitHubToGitLabRepos(githubRepo string, gitlabRepos []gitlab.Repo, t *stats.Table, org, projectID string) {
// for _, gitLabRepo := range gitlabRepos {
// if gitLabRepo.Name == githubRepo {
// t.AddRow([]string{githubRepo, ":white_check_mark:", org, ":white_check_mark:", projectID})
// }
// }
// t.AddRow([]string{githubRepo, ":x:", org, ":white_check_mark:", projectID})
//}
//
//func compareGitLabToGitHubRepos(gitLabRepo string, githubRepos []github.Repo, t *stats.Table, org, projectID string) {
// for _, githubRepo := range githubRepos {
// if githubRepo.Name != gitLabRepo {
// t.AddRow([]string{gitLabRepo, ":x:", org, ":white_check_mark:", projectID})
// }
// }
//}