Skip to content

Commit baa1779

Browse files
committed
use go-gitapi/v3
1 parent eb4f629 commit baa1779

40 files changed

Lines changed: 322 additions & 347 deletions

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,5 @@
117117
- refactor repo output to lib.RepoOutput()
118118
- update dependencies
119119
- update go-gitcmd
120+
- v3.0.0
121+
- use go-gitapi/v3

cmd/repoDelRepo.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
28+
"github.com/J-Siu/go-gitapi/v3/api"
2929
"github.com/J-Siu/go-mygit/v2/global"
3030
"github.com/J-Siu/go-mygit/v2/lib"
3131
"github.com/spf13/cobra"
@@ -39,7 +39,7 @@ var repoDelRepoCmd = &cobra.Command{
3939
Long: "Delete remote repository. " + global.TXT_REPO_DIR_LONG,
4040
Run: func(cmd *cobra.Command, args []string) {
4141
var (
42-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4343
wg sync.WaitGroup
4444
)
4545

@@ -51,10 +51,11 @@ var repoDelRepoCmd = &cobra.Command{
5151
go func() {
5252
for _, workPath := range args {
5353
for _, remote := range global.Conf.MergedRemotes {
54-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, nil, global.Flag.Debug)
55-
gitApi.EndpointRepos()
56-
gitApi.SetDel()
57-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
54+
var (
55+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
56+
ga = new(api.Repo).New(property).Del()
57+
)
58+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5859
}
5960
}
6061
wg.Wait()

cmd/repoDelSecret.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ package cmd
2424

2525
import (
2626
"fmt"
27-
"path"
2827
"sync"
2928

30-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29+
"github.com/J-Siu/go-gitapi/v3/api"
30+
"github.com/J-Siu/go-gitapi/v3/base"
3131
"github.com/J-Siu/go-mygit/v2/global"
3232
"github.com/J-Siu/go-mygit/v2/lib"
3333
"github.com/spf13/cobra"
@@ -41,7 +41,7 @@ var repoDelSecretCmd = &cobra.Command{
4141
Long: "Delete action secret. If --name is not set, all secrets in config will be used. " + global.TXT_REPO_DIR_LONG,
4242
Run: func(cmd *cobra.Command, args []string) {
4343
var (
44-
out = make(chan *gitapi.GitApi, 10)
44+
out = make(chan api.IApi, 10)
4545
wg sync.WaitGroup
4646
)
4747
// If no repo specified in command line, add a ""
@@ -57,15 +57,15 @@ var repoDelSecretCmd = &cobra.Command{
5757
go func() {
5858
for _, workPath := range args {
5959
for _, remote := range global.Conf.MergedRemotes {
60-
if remote.Vendor != gitapi.VendorGithub {
60+
if remote.Vendor != base.VendorGithub {
6161
fmt.Printf("%s(%s) action secret not supported.\n", remote.Name, remote.Vendor)
6262
} else {
6363
for _, secret := range global.Flag.SecretsDel {
64-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, nil, global.Flag.Debug)
65-
gitApi.EndpointReposSecrets()
66-
gitApi.Req.Endpoint = path.Join(gitApi.Req.Endpoint, secret)
67-
gitApi.SetDel()
68-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
64+
var (
65+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
66+
ga = new(api.Repo).New(property).DelSecret(secret)
67+
)
68+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
6969
}
7070
}
7171
}

cmd/repoGetActions.go

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,8 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29-
"github.com/J-Siu/go-gitapi/v2/repo"
28+
"github.com/J-Siu/go-gitapi/v3/api"
29+
"github.com/J-Siu/go-gitapi/v3/base"
3030
"github.com/J-Siu/go-mygit/v2/global"
3131
"github.com/J-Siu/go-mygit/v2/lib"
3232
"github.com/spf13/cobra"
@@ -40,7 +40,7 @@ var repoGetActionsCmd = &cobra.Command{
4040
Long: "Get wiki status. " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4141
Run: func(cmd *cobra.Command, args []string) {
4242
var (
43-
out = make(chan *gitapi.GitApi, 10)
43+
out = make(chan api.IApi, 10)
4444
wg sync.WaitGroup
4545
)
4646
if len(args) == 0 {
@@ -50,19 +50,15 @@ var repoGetActionsCmd = &cobra.Command{
5050
for _, workPath := range args {
5151
for _, remote := range global.Conf.MergedRemotes {
5252
var (
53-
info gitapi.IInfo
54-
gitApi *gitapi.GitApi
53+
ga api.IApi
54+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
5555
)
56-
if remote.Vendor == gitapi.VendorGithub {
57-
info = &repo.ActionsGithub{} // Github API
58-
gitApi = remote.GetGitApi(&workPath, info, global.Flag.Debug).EndpointReposActionsGithub()
56+
if remote.Vendor == base.VendorGithub {
57+
ga = new(api.ActionsGithub).New(property).Get()
5958
} else {
60-
info = &repo.Actions{} // Gitea API
61-
gitApi = remote.GetGitApi(&workPath, info, global.Flag.Debug).EndpointRepos()
59+
ga = new(api.Actions).New(property).Get()
6260
}
63-
64-
gitApi.SetGet()
65-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
61+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
6662
}
6763
}
6864
wg.Wait()

cmd/repoGetArchived.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29-
"github.com/J-Siu/go-gitapi/v2/repo"
28+
"github.com/J-Siu/go-gitapi/v3/api"
3029
"github.com/J-Siu/go-mygit/v2/global"
3130
"github.com/J-Siu/go-mygit/v2/lib"
3231
"github.com/spf13/cobra"
@@ -40,7 +39,7 @@ var repoGetArchivedCmd = &cobra.Command{
4039
Long: "Get archived status. " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4140
Run: func(cmd *cobra.Command, args []string) {
4241
var (
43-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4443
wg sync.WaitGroup
4544
)
4645
if len(args) == 0 {
@@ -50,12 +49,10 @@ var repoGetArchivedCmd = &cobra.Command{
5049
for _, workPath := range args {
5150
for _, remote := range global.Conf.MergedRemotes {
5251
var (
53-
info repo.Archived
54-
gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, &info, global.Flag.Debug)
52+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
53+
ga = new(api.Archived).New(property).Get()
5554
)
56-
gitApi.EndpointRepos()
57-
gitApi.SetGet()
58-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
55+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5956
}
6057
}
6158
wg.Wait()

cmd/repoGetDescription.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29-
"github.com/J-Siu/go-gitapi/v2/repo"
28+
"github.com/J-Siu/go-gitapi/v3/api"
3029
"github.com/J-Siu/go-mygit/v2/global"
3130
"github.com/J-Siu/go-mygit/v2/lib"
3231
"github.com/spf13/cobra"
@@ -40,7 +39,7 @@ var repoGetDescriptionCmd = &cobra.Command{
4039
Long: "Get description. " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4140
Run: func(cmd *cobra.Command, args []string) {
4241
var (
43-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4443
wg sync.WaitGroup
4544
)
4645
if len(args) == 0 {
@@ -49,11 +48,11 @@ var repoGetDescriptionCmd = &cobra.Command{
4948
go func() {
5049
for _, workPath := range args {
5150
for _, remote := range global.Conf.MergedRemotes {
52-
var info repo.Description
53-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, &info, global.Flag.Debug)
54-
gitApi.EndpointRepos()
55-
gitApi.SetGet()
56-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
51+
var (
52+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
53+
ga = new(api.Description).New(property).Get()
54+
)
55+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5756
}
5857
}
5958
wg.Wait()

cmd/repoGetDiscussions.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29-
"github.com/J-Siu/go-gitapi/v2/repo"
28+
"github.com/J-Siu/go-gitapi/v3/api"
3029
"github.com/J-Siu/go-mygit/v2/global"
3130
"github.com/J-Siu/go-mygit/v2/lib"
3231
"github.com/spf13/cobra"
@@ -40,7 +39,7 @@ var repoGetDiscussionsCmd = &cobra.Command{
4039
Long: "Get discussions status. " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4140
Run: func(cmd *cobra.Command, args []string) {
4241
var (
43-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4443
wg sync.WaitGroup
4544
)
4645
if len(args) == 0 {
@@ -49,11 +48,11 @@ var repoGetDiscussionsCmd = &cobra.Command{
4948
go func() {
5049
for _, workPath := range args {
5150
for _, remote := range global.Conf.MergedRemotes {
52-
var info repo.Discussions
53-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, &info, global.Flag.Debug)
54-
gitApi.EndpointRepos()
55-
gitApi.SetGet()
56-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
51+
var (
52+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
53+
ga = new(api.Discussions).New(property).Get()
54+
)
55+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5756
}
5857
}
5958
wg.Wait()

cmd/repoGetInfo.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
28+
"github.com/J-Siu/go-gitapi/v3/api"
2929
"github.com/J-Siu/go-mygit/v2/global"
3030
"github.com/J-Siu/go-mygit/v2/lib"
3131
"github.com/spf13/cobra"
@@ -39,7 +39,7 @@ var repoGetInfoCmd = &cobra.Command{
3939
Long: "Get info(json). " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4040
Run: func(cmd *cobra.Command, args []string) {
4141
var (
42-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4343
wg sync.WaitGroup
4444
)
4545
if len(args) == 0 {
@@ -48,10 +48,11 @@ var repoGetInfoCmd = &cobra.Command{
4848
go func() {
4949
for _, workPath := range args {
5050
for _, remote := range global.Conf.MergedRemotes {
51-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, nil, global.Flag.Debug)
52-
gitApi.EndpointRepos()
53-
gitApi.SetGet()
54-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
51+
var (
52+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
53+
ga = new(api.Info).New(property).Get()
54+
)
55+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5556
}
5657
}
5758
wg.Wait()

cmd/repoGetPrivate.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29-
"github.com/J-Siu/go-gitapi/v2/repo"
28+
"github.com/J-Siu/go-gitapi/v3/api"
3029
"github.com/J-Siu/go-mygit/v2/global"
3130
"github.com/J-Siu/go-mygit/v2/lib"
3231
"github.com/spf13/cobra"
@@ -40,7 +39,7 @@ var repoGetPrivateCmd = &cobra.Command{
4039
Long: "Get private status. " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4140
Run: func(cmd *cobra.Command, args []string) {
4241
var (
43-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4443
wg sync.WaitGroup
4544
)
4645
if len(args) == 0 {
@@ -49,11 +48,11 @@ var repoGetPrivateCmd = &cobra.Command{
4948
go func() {
5049
for _, workPath := range args {
5150
for _, remote := range global.Conf.MergedRemotes {
52-
var info repo.Private
53-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, &info, global.Flag.Debug)
54-
gitApi.EndpointRepos()
55-
gitApi.SetGet()
56-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
51+
var (
52+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
53+
ga = new(api.Private).New(property).Get()
54+
)
55+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5756
}
5857
}
5958
wg.Wait()

cmd/repoGetProjects.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ package cmd
2525
import (
2626
"sync"
2727

28-
"github.com/J-Siu/go-gitapi/v2/gitapi"
29-
"github.com/J-Siu/go-gitapi/v2/repo"
28+
"github.com/J-Siu/go-gitapi/v3/api"
3029
"github.com/J-Siu/go-mygit/v2/global"
3130
"github.com/J-Siu/go-mygit/v2/lib"
3231
"github.com/spf13/cobra"
@@ -40,7 +39,7 @@ var repoGetProjectsCmd = &cobra.Command{
4039
Long: "Get projects status. " + global.TXT_REPO_DIR_LONG + global.TXT_FLAGS_USE,
4140
Run: func(cmd *cobra.Command, args []string) {
4241
var (
43-
out = make(chan *gitapi.GitApi, 10)
42+
out = make(chan api.IApi, 10)
4443
wg sync.WaitGroup
4544
)
4645
if len(args) == 0 {
@@ -49,11 +48,11 @@ var repoGetProjectsCmd = &cobra.Command{
4948
go func() {
5049
for _, workPath := range args {
5150
for _, remote := range global.Conf.MergedRemotes {
52-
var info repo.Projects
53-
var gitApi *gitapi.GitApi = remote.GetGitApi(&workPath, &info, global.Flag.Debug)
54-
gitApi.EndpointRepos()
55-
gitApi.SetGet()
56-
lib.RepoDoRun(gitApi, global.Flag.NoParallel, &wg, out)
51+
var (
52+
property = remote.GitApiProperty(&workPath, global.Flag.Debug)
53+
ga = new(api.Projects).New(property).SetGet()
54+
)
55+
lib.RepoDoRun(ga, global.Flag.NoParallel, &wg, out)
5756
}
5857
}
5958
wg.Wait()

0 commit comments

Comments
 (0)