From 0d2baa2c732bc3f18c7a72c6f095bd25211b6b75 Mon Sep 17 00:00:00 2001 From: Vitalie Safronovici Date: Tue, 16 Jul 2024 18:12:21 +0300 Subject: [PATCH 1/4] fix: [IAC-2201]: fixed looping endless pagination --- scm/driver/bitbucket/git.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scm/driver/bitbucket/git.go b/scm/driver/bitbucket/git.go index 181c9fa3..e56f8508 100644 --- a/scm/driver/bitbucket/git.go +++ b/scm/driver/bitbucket/git.go @@ -88,9 +88,12 @@ func (s *gitService) ListTags(ctx context.Context, repo string, opts scm.ListOpt out := new(branches) res, err := s.client.do(ctx, "GET", path, nil, &out) - if res != nil { - res.Page.Next = 0 - } + // if res != nil { + // res.Page.Next = 0 + // } + + fmt.Printf("xxxxx res=%+v", res) + fmt.Printf("xxxxx out=%+v", out) copyPagination(out.pagination, res) return convertTagList(out), res, err From 8aca10b1b3a386a99d79fbbfbd6c7ba782aae243 Mon Sep 17 00:00:00 2001 From: Vitalie Safronovici Date: Tue, 16 Jul 2024 19:37:28 +0300 Subject: [PATCH 2/4] adjust --- scm/driver/bitbucket/git.go | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/scm/driver/bitbucket/git.go b/scm/driver/bitbucket/git.go index e56f8508..6c703a7b 100644 --- a/scm/driver/bitbucket/git.go +++ b/scm/driver/bitbucket/git.go @@ -88,14 +88,15 @@ func (s *gitService) ListTags(ctx context.Context, repo string, opts scm.ListOpt out := new(branches) res, err := s.client.do(ctx, "GET", path, nil, &out) - // if res != nil { - // res.Page.Next = 0 - // } + copyPagination(out.pagination, res) + + if res != nil { + res.Page.Next = 0 + } - fmt.Printf("xxxxx res=%+v", res) - fmt.Printf("xxxxx out=%+v", out) + fmt.Printf("xxxxx res=%+v\n", res) + fmt.Printf("xxxxx out=%+v\n", out) - copyPagination(out.pagination, res) return convertTagList(out), res, err } From f3725efa115cc9ee7b7875790ed115daf20805ab Mon Sep 17 00:00:00 2001 From: Vitalie Safronovici Date: Tue, 16 Jul 2024 20:10:22 +0300 Subject: [PATCH 3/4] removed logs --- scm/driver/bitbucket/git.go | 3 --- 1 file changed, 3 deletions(-) diff --git a/scm/driver/bitbucket/git.go b/scm/driver/bitbucket/git.go index 6c703a7b..e0ecc554 100644 --- a/scm/driver/bitbucket/git.go +++ b/scm/driver/bitbucket/git.go @@ -94,9 +94,6 @@ func (s *gitService) ListTags(ctx context.Context, repo string, opts scm.ListOpt res.Page.Next = 0 } - fmt.Printf("xxxxx res=%+v\n", res) - fmt.Printf("xxxxx out=%+v\n", out) - return convertTagList(out), res, err } From be67dd5203b89c912dc3dd50dc3e247480418c41 Mon Sep 17 00:00:00 2001 From: Vitalie Safronovici Date: Tue, 16 Jul 2024 20:18:53 +0300 Subject: [PATCH 4/4] fixed UT --- scm/driver/bitbucket/git_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scm/driver/bitbucket/git_test.go b/scm/driver/bitbucket/git_test.go index c04c26d5..e9349980 100644 --- a/scm/driver/bitbucket/git_test.go +++ b/scm/driver/bitbucket/git_test.go @@ -250,7 +250,7 @@ func TestGitListTags(t *testing.T) { File("testdata/tags.json") client, _ := New("https://api.bitbucket.org") - got, res, err := client.Git.ListTags(context.Background(), "atlassian/atlaskit", scm.ListOptions{Page: 1, Size: 30}) + got, _, err := client.Git.ListTags(context.Background(), "atlassian/atlaskit", scm.ListOptions{Page: 1, Size: 30}) if err != nil { t.Error(err) } @@ -264,7 +264,6 @@ func TestGitListTags(t *testing.T) { t.Log(diff) } - t.Run("Page", testPage(res)) } func TestGitListChanges(t *testing.T) {