Skip to content

Commit 4067b48

Browse files
authored
Fixes for dependabot update (#610)
1 parent aa326cf commit 4067b48

File tree

4 files changed

+68
-46
lines changed

4 files changed

+68
-46
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,17 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
55

66
## [1.11.8] - unreleased
77
### Added
8+
- Bitbucket Cloud API token authentication support; thanks @dean-tate
89
### Changed
910
### Deprecated
1011
### Removed
1112
### Fixed
1213
### Security
14+
- Bump golang.org/x/oauth2 from 0.32.0 to 0.34.0 (#607)
15+
- Bump github.com/ktrysmt/go-bitbucket from 0.9.87 to 0.9.88 (#606)
16+
- Bump github.com/spf13/cobra from 1.10.1 to 1.10.2 (#608)
17+
- Bump gitlab.com/gitlab-org/api/client-go from 0.157.1 to 1.10.0 (#609)
18+
1319

1420
## [1.11.7] - 12/6/25
1521
### Added

scm/bitbucket.go

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,19 +120,31 @@ func (_ Bitbucket) NewClient() (Client, error) {
120120

121121
if oAuth != "" {
122122
// OAuth bearer token takes precedence
123-
c = bitbucket.NewOAuthbearerToken(oAuth)
123+
var err error
124+
c, err = bitbucket.NewOAuthbearerToken(oAuth)
125+
if err != nil {
126+
return nil, fmt.Errorf("failed to create OAuth bearer token client: %v", err)
127+
}
124128
} else if apiToken != "" {
125129
// New API Token authentication
126130
// For API calls, use email (or username as fallback) with the API token
127131
apiUser := apiEmail
128132
if apiUser == "" {
129133
apiUser = user // Fall back to username if email not provided
130134
}
131-
c = bitbucket.NewBasicAuth(apiUser, apiToken)
135+
var err error
136+
c, err = bitbucket.NewBasicAuth(apiUser, apiToken)
137+
if err != nil {
138+
return nil, fmt.Errorf("failed to create API token client: %v", err)
139+
}
132140
useAPIToken = true
133141
} else {
134142
// Legacy App Password authentication
135-
c = bitbucket.NewBasicAuth(user, password)
143+
var err error
144+
c, err = bitbucket.NewBasicAuth(user, password)
145+
if err != nil {
146+
return nil, fmt.Errorf("failed to create basic auth client: %v", err)
147+
}
136148
}
137149

138150
return Bitbucket{

scm/gitlab.go

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ func (c Gitlab) GetOrgRepos(targetOrg string) ([]Repo, error) {
116116
func (c Gitlab) GetTopLevelGroups() ([]string, error) {
117117
opt := &gitlab.ListGroupsOptions{
118118
ListOptions: gitlab.ListOptions{
119-
PerPage: perPage,
119+
PerPage: int64(perPage),
120120
Page: 1,
121121
},
122122
TopLevelOnly: &[]bool{true}[0],
@@ -139,7 +139,7 @@ func (c Gitlab) GetTopLevelGroups() ([]string, error) {
139139
}
140140

141141
// Multiple pages - fetch remaining pages in parallel
142-
return c.fetchTopLevelGroupsParallel(groups, resp.TotalPages)
142+
return c.fetchTopLevelGroupsParallel(groups, int(resp.TotalPages))
143143
}
144144

145145
// In this case take the cloneURL from the cloneTartet repo and just inject /snippets/:id before the .git
@@ -198,8 +198,10 @@ func (c Gitlab) createRootLevelSnippetCloneURL(snippetWebURL string) string {
198198
func (c Gitlab) getRepoSnippets(r Repo) []*gitlab.Snippet {
199199
var allSnippets []*gitlab.Snippet
200200
opt := &gitlab.ListProjectSnippetsOptions{
201-
PerPage: perPage,
202-
Page: 1,
201+
ListOptions: gitlab.ListOptions{
202+
PerPage: int64(perPage),
203+
Page: 1,
204+
},
203205
}
204206

205207
for {
@@ -232,7 +234,7 @@ func (c Gitlab) getAllSnippets() []*gitlab.Snippet {
232234
var allSnippets []*gitlab.Snippet
233235
opt := &gitlab.ListAllSnippetsOptions{
234236
ListOptions: gitlab.ListOptions{
235-
PerPage: perPage,
237+
PerPage: int64(perPage),
236238
Page: 1,
237239
},
238240
}
@@ -307,7 +309,7 @@ func (c Gitlab) GetSnippets(cloneData []Repo, target string) ([]Repo, error) {
307309
}
308310

309311
for _, snippet := range allSnippetsToClone {
310-
snippetID := strconv.Itoa(snippet.ID)
312+
snippetID := strconv.FormatInt(snippet.ID, 10)
311313
snippetTitle := ToSlug(snippet.Title)
312314
s := Repo{}
313315
s.IsGitLabSnippet = true
@@ -324,7 +326,7 @@ func (c Gitlab) GetSnippets(cloneData []Repo, target string) ([]Repo, error) {
324326
} else {
325327
// Since this isn't a root level repo we want to find which repo the snippet is coming from
326328
for _, cloneTarget := range cloneData {
327-
if cloneTarget.ID == strconv.Itoa(snippet.ProjectID) {
329+
if cloneTarget.ID == strconv.FormatInt(snippet.ProjectID, 10) {
328330
s.CloneURL = c.createRepoSnippetCloneURL(cloneTarget.CloneURL, snippetID)
329331
s.Path = cloneTarget.Path
330332
s.GitLabSnippetInfo.URLOfRepo = cloneTarget.URL
@@ -344,7 +346,7 @@ func (c Gitlab) GetSnippets(cloneData []Repo, target string) ([]Repo, error) {
344346
func (c Gitlab) GetGroupRepos(targetGroup string) ([]Repo, error) {
345347
opt := &gitlab.ListGroupProjectsOptions{
346348
ListOptions: gitlab.ListOptions{
347-
PerPage: perPage,
349+
PerPage: int64(perPage),
348350
Page: 1,
349351
},
350352
IncludeSubGroups: gitlab.Ptr(true),
@@ -365,7 +367,7 @@ func (c Gitlab) GetGroupRepos(targetGroup string) ([]Repo, error) {
365367
}
366368

367369
// Multiple pages - fetch remaining pages in parallel
368-
return c.fetchGroupReposParallel(targetGroup, ps, resp.TotalPages)
370+
return c.fetchGroupReposParallel(targetGroup, ps, int(resp.TotalPages))
369371
}
370372

371373
// GetUserRepos gets all of a users gitlab repos
@@ -375,14 +377,14 @@ func (c Gitlab) GetUserRepos(targetUsername string) ([]Repo, error) {
375377

376378
projectOpts := &gitlab.ListProjectsOptions{
377379
ListOptions: gitlab.ListOptions{
378-
PerPage: perPage,
380+
PerPage: int64(perPage),
379381
Page: 1,
380382
},
381383
}
382384

383385
userOpts := &gitlab.ListUsersOptions{
384386
ListOptions: gitlab.ListOptions{
385-
PerPage: perPage,
387+
PerPage: int64(perPage),
386388
Page: 1,
387389
},
388390
}
@@ -520,7 +522,7 @@ func (c Gitlab) filter(group string, ps []*gitlab.Project) []Repo {
520522
r := Repo{}
521523

522524
r.Name = p.Name
523-
r.ID = strconv.Itoa(p.ID)
525+
r.ID = strconv.FormatInt(int64(p.ID), 10)
524526

525527
if os.Getenv("GHORG_BRANCH") == "" {
526528
defaultBranch := p.DefaultBranch

scm/gitlab_parallel.go

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@ func (c Gitlab) fetchTopLevelGroupsParallel(firstPageGroups []*gitlab.Group, tot
3737
go func(pageNum int) {
3838
defer wg.Done()
3939

40-
opt := &gitlab.ListGroupsOptions{
41-
ListOptions: gitlab.ListOptions{
42-
PerPage: perPage,
43-
Page: pageNum,
44-
},
45-
TopLevelOnly: &[]bool{true}[0],
46-
AllAvailable: &[]bool{true}[0],
47-
}
40+
opt := &gitlab.ListGroupsOptions{
41+
ListOptions: gitlab.ListOptions{
42+
PerPage: int64(perPage),
43+
Page: int64(pageNum),
44+
},
45+
TopLevelOnly: &[]bool{true}[0],
46+
AllAvailable: &[]bool{true}[0],
47+
}
4848

4949
groups, _, err := c.Client.Groups.ListGroups(opt)
5050
resultChan <- pageResult{groups: groups, err: err, page: pageNum}
@@ -101,13 +101,13 @@ func (c Gitlab) fetchGroupReposParallel(targetGroup string, firstPageProjects []
101101
go func(pageNum int) {
102102
defer wg.Done()
103103

104-
opt := &gitlab.ListGroupProjectsOptions{
105-
ListOptions: gitlab.ListOptions{
106-
PerPage: perPage,
107-
Page: pageNum,
108-
},
109-
IncludeSubGroups: gitlab.Ptr(true),
110-
}
104+
opt := &gitlab.ListGroupProjectsOptions{
105+
ListOptions: gitlab.ListOptions{
106+
PerPage: int64(perPage),
107+
Page: int64(pageNum),
108+
},
109+
IncludeSubGroups: gitlab.Ptr(true),
110+
}
111111

112112
ps, _, err := c.Groups.ListGroupProjects(targetGroup, opt)
113113
resultChan <- pageResult{projects: ps, err: err, page: pageNum}
@@ -164,12 +164,12 @@ func (c Gitlab) fetchUserProjectsParallel(targetUser string, firstPageProjects [
164164
go func(pageNum int) {
165165
defer wg.Done()
166166

167-
projectOpts := &gitlab.ListProjectsOptions{
168-
ListOptions: gitlab.ListOptions{
169-
PerPage: perPage,
170-
Page: pageNum,
171-
},
172-
}
167+
projectOpts := &gitlab.ListProjectsOptions{
168+
ListOptions: gitlab.ListOptions{
169+
PerPage: int64(perPage),
170+
Page: int64(pageNum),
171+
},
172+
}
173173

174174
projects, _, err := c.Projects.ListProjects(projectOpts, gitlab.WithContext(context.Background()))
175175
resultChan <- pageResult{projects: projects, err: err, page: pageNum}
@@ -224,10 +224,12 @@ func (c Gitlab) fetchRepoSnippetsParallel(repoID string, firstPageSnippets []*gi
224224
go func(pageNum int) {
225225
defer wg.Done()
226226

227-
opt := &gitlab.ListProjectSnippetsOptions{
228-
PerPage: perPage,
229-
Page: pageNum,
230-
}
227+
opt := &gitlab.ListProjectSnippetsOptions{
228+
ListOptions: gitlab.ListOptions{
229+
PerPage: int64(perPage),
230+
Page: int64(pageNum),
231+
},
232+
}
231233

232234
snippets, _, err := c.ProjectSnippets.ListSnippets(repoID, opt)
233235
resultChan <- pageResult{snippets: snippets, err: err, page: pageNum}
@@ -284,12 +286,12 @@ func (c Gitlab) fetchAllSnippetsParallel(firstPageSnippets []*gitlab.Snippet, to
284286
go func(pageNum int) {
285287
defer wg.Done()
286288

287-
opt := &gitlab.ListAllSnippetsOptions{
288-
ListOptions: gitlab.ListOptions{
289-
PerPage: perPage,
290-
Page: pageNum,
291-
},
292-
}
289+
opt := &gitlab.ListAllSnippetsOptions{
290+
ListOptions: gitlab.ListOptions{
291+
PerPage: int64(perPage),
292+
Page: int64(pageNum),
293+
},
294+
}
293295

294296
snippets, _, err := c.Snippets.ListAllSnippets(opt)
295297
resultChan <- pageResult{snippets: snippets, err: err, page: pageNum}

0 commit comments

Comments
 (0)