8000 fix(vcs): get commit status for bitbucket, missing pagination params … · ovh/cds@97e7c6d · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Commit 97e7c6d

Browse files
authored
fix(vcs): get commit status for bitbucket, missing pagination params (#4988)
1 parent 29ef4c2 commit 97e7c6d

24 files changed

+307
-242
lines changed

engine/api/workflow_import.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -296,8 +296,7 @@ func (api *API) postWorkflowPushHandler() service.Handler {
296296

297297
btes, err := ioutil.ReadAll(r.Body)
298298
if err != nil {
299-
log.Error(ctx, "postWorkflowPushHandler> Unable to read body: %v", err)
300-
return sdk.WithStack(sdk.ErrWrongRequest)
299+
return sdk.NewErrorWithStack(err, sdk.ErrWrongRequest)
301300
}
302301
defer r.Body.Close()
303302

@@ -316,15 +315,15 @@ func (api *API) postWorkflowPushHandler() service.Handler {
316315
u := getAPIConsumer(ctx)
317316

318317
//Load project
319-
proj, errp := project.Load(db, api.Cache, key,
318+
proj, err := project.Load(db, api.Cache, key,
320319
project.LoadOptions.WithGroups,
321320
project.LoadOptions.WithApplications,
322321
project.LoadOptions.WithEnvironments,
323322
project.LoadOptions.WithPipelines,
324323
project.LoadOptions.WithApplicationWithDeploymentStrategies,
325324
project.LoadOptions.WithIntegrations)
326-
if errp != nil {
327-
return sdk.WrapError(errp, "postWorkflowPushHandler> Cannot load project %s", key)
325+
if err != nil {
326+
return sdk.WrapError(err, "cannot load project %s", key)
328327
}
329328

330329
allMsg, wrkflw, oldWrkflw, err := workflow.Push(ctx, db, api.Cache, proj, tr, pushOptions, u, project.DecryptWithBuiltinKey)

engine/vcs/bitbucketcloud/client_branch.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func (client *bitbucketcloudClient) Branches(ctx context.Context, fullname strin
2424
params.Set("sort", "-target.date")
2525
nextPage := 1
2626
for {
27+
if ctx.Err() != nil {
28+
break
29+
}
30+
2731
if nextPage != 1 {
2832
params.Set("page", fmt.Sprintf("%d", nextPage))
2933
}

engine/vcs/bitbucketcloud/client_commit.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ func (client *bitbucketcloudClient) allCommitBetween(ctx context.Context, repo,
5151
nextPage := 1
5252

5353
for {
54+
if ctx.Err() != nil {
55+
break
56+
}
57+
5458
if nextPage != 1 {
5559
params.Set("page", fmt.Sprintf("%d", nextPage))
5660
}
@@ -122,6 +126,10 @@ func (client *bitbucketcloudClient) CommitsBetweenRefs(ctx context.Context, repo
122126
path := fmt.Sprintf("/repositories/%s/commits/%s", repo, head)
123127
nextPage := 1
124128
for {
129+
if ctx.Err() != nil {
130+
break
131+
}
132+
125133
if nextPage != 1 {
126134
params.Set("page", fmt.Sprintf("%d", nextPage))
127135
}

engine/vcs/bitbucketcloud/client_forks.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ func (client *bitbucketcloudClient) ListForks(ctx context.Context, repo string)
1515
params.Set("pagelen", "100")
1616
nextPage := 1
1717
for {
18+
if ctx.Err() != nil {
19+
break
20+
}
21+
1822
if nextPage != 1 {
1923
params.Set("page", fmt.Sprintf("%d", nextPage))
2024
}

engine/vcs/bitbucketcloud/client_hook.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,10 @@ func (client *bitbucketcloudClient) getHooks(ctx context.Context, fullname strin
6565
params.Set("pagelen", "100")
6666
nextPage := 1
6767
for {
68+
if ctx.Err() != nil {
69+
break
70+
}
71+
6872
if nextPage != 1 {
6973
params.Set("page", fmt.Sprintf("%d", nextPage))
7074
}

engine/vcs/bitbucketcloud/client_pull_request.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ func (client *bitbucketcloudClient) PullRequests(ctx context.Context, fullname s
3939
params.Set("pagelen", "50")
4040
nextPage := 1
4141
for {
42+
if ctx.Err() != nil {
43+
break
44+
}
45+
4246
if nextPage != 1 {
4347
params.Set("page", fmt.Sprintf("%d", nextPage))
4448
}

engine/vcs/bitbucketcloud/client_repos.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ func (client *bitbucketcloudClient) reposForUser(ctx context.Context, username s
6363
params.Set("role", "member")
6464
nextPage := 1
6565
for {
66+
if ctx.Err() != nil {
67+
break
68+
}
69+
6670
if nextPage != 1 {
6771
params.Set("page", fmt.Sprintf("%d", nextPage))
6872
}

engine/vcs/bitbucketserver/client_branch.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,10 @@ func (b *bitbucketClient) Branches(ctx context.Context, fullname string) ([]sdk.
2424

2525
nextPage := 0
2626
for {
27+
if ctx.Err() != nil {
28+
break
29+
}
30+
2731
if nextPage != 0 {
2832
params.Set("start", fmt.Sprintf("%d", nextPage))
2933
}

engine/vcs/bitbucketserver/client_commit.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ func (b *bitbucketClient) Commits(ctx context.Context, repo, branch, since, unti
3737
}
3838

3939
for {
40+
if ctx.Err() != nil {
41+
break
42+
}
43+
4044
if response.NextPageStart != 0 {
4145
params.Set("start", fmt.Sprintf("%d", response.NextPageStart))
4246
}

engine/vcs/bitbucketserver/client_forks.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ func (b *bitbucketClient) ListForks(ctx context.Context, repo string) ([]sdk.VCS
1818
params := url.Values{}
1919
nextPage := 0
2020
for {
21+
if ctx.Err() != nil {
22+
break
23+
}
24+
2125
if nextPage != 0 {
2226
params.Set("start", fmt.Sprintf("%d", nextPage))
2327
}

0 commit comments

Comments
 (0)
0