From d60cf9644019c3b57c3ac8fc76fffafb63440fe7 Mon Sep 17 00:00:00 2001 From: Heiko Does Date: Tue, 28 Sep 2021 12:32:27 +0200 Subject: [PATCH 1/2] fix: GH-300 --- scm/driver/gitlab/testdata/webhooks/pull_request_close.json | 2 +- .../gitlab/testdata/webhooks/pull_request_comment_create.json | 2 +- scm/driver/gitlab/testdata/webhooks/pull_request_create.json | 2 +- scm/driver/gitlab/testdata/webhooks/pull_request_edited.json | 2 +- scm/driver/gitlab/testdata/webhooks/pull_request_merge.json | 2 +- scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json | 2 +- scm/driver/gitlab/webhook.go | 4 ++-- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_close.json b/scm/driver/gitlab/testdata/webhooks/pull_request_close.json index 3be097117..dca2acae9 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_close.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_close.json @@ -37,7 +37,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": "0" + "force_remove_source_branch": false }, "merge_status": "can_be_merged", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json b/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json index ca26a5cb3..037c7e3d2 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json @@ -69,7 +69,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": "0" + "force_remove_source_branch": false }, "merge_status": "can_be_merged", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_create.json b/scm/driver/gitlab/testdata/webhooks/pull_request_create.json index 91a8a3117..375232cad 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_create.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_create.json @@ -37,7 +37,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": "0" + "force_remove_source_branch": false }, "merge_status": "unchecked", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json b/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json index 0b7a46da9..9876928c6 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json @@ -37,7 +37,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": "0" + "force_remove_source_branch": false }, "merge_status": "unchecked", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_merge.json b/scm/driver/gitlab/testdata/webhooks/pull_request_merge.json index 2f0b4386e..f25437a37 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_merge.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_merge.json @@ -37,7 +37,7 @@ "merge_commit_sha": "78a76ee6b4992a6baf64c59fc4c44c7323d60438", "merge_error": null, "merge_params": { - "force_remove_source_branch": "0" + "force_remove_source_branch": false }, "merge_status": "can_be_merged", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json b/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json index 965448772..0ead6d721 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json @@ -37,7 +37,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": "0" + "force_remove_source_branch": false }, "merge_status": "can_be_merged", "merge_user_id": null, diff --git a/scm/driver/gitlab/webhook.go b/scm/driver/gitlab/webhook.go index 980192efe..62f77e781 100644 --- a/scm/driver/gitlab/webhook.go +++ b/scm/driver/gitlab/webhook.go @@ -613,7 +613,7 @@ type ( MergeCommitSha string `json:"merge_commit_sha"` MergeError interface{} `json:"merge_error"` MergeParams struct { - ForceRemoveSourceBranch string `json:"force_remove_source_branch"` + ForceRemoveSourceBranch bool `json:"force_remove_source_branch"` } `json:"merge_params"` MergeStatus string `json:"merge_status"` MergeUserID interface{} `json:"merge_user_id"` @@ -814,7 +814,7 @@ type ( MergeCommitSha string `json:"merge_commit_sha"` MergeError interface{} `json:"merge_error"` MergeParams struct { - ForceRemoveSourceBranch string `json:"force_remove_source_branch"` + ForceRemoveSourceBranch bool `json:"force_remove_source_branch"` } `json:"merge_params"` MergeStatus string `json:"merge_status"` MergeUserID interface{} `json:"merge_user_id"` From 02d29804b9c92164965cad2a970bce9fd3dee4c6 Mon Sep 17 00:00:00 2001 From: Heiko Does Date: Fri, 14 Oct 2022 08:59:19 +0200 Subject: [PATCH 2/2] fix: flanky force_remove_source_branch type Gitlab MergeRequestHook have unstable json type for this property. https://gitlab.com/gitlab-org/gitlab/-/issues/15647 closes jenkins-x/go-scm#300 --- .../gitlab/testdata/webhooks/pull_request_comment_create.json | 2 +- scm/driver/gitlab/testdata/webhooks/pull_request_edited.json | 2 +- scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json | 2 +- scm/driver/gitlab/webhook.go | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json b/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json index 037c7e3d2..ca26a5cb3 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_comment_create.json @@ -69,7 +69,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": false + "force_remove_source_branch": "0" }, "merge_status": "can_be_merged", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json b/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json index 9876928c6..0b7a46da9 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_edited.json @@ -37,7 +37,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": false + "force_remove_source_branch": "0" }, "merge_status": "unchecked", "merge_user_id": null, diff --git a/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json b/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json index 0ead6d721..965448772 100644 --- a/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json +++ b/scm/driver/gitlab/testdata/webhooks/pull_request_reopen.json @@ -37,7 +37,7 @@ "merge_commit_sha": null, "merge_error": null, "merge_params": { - "force_remove_source_branch": false + "force_remove_source_branch": "0" }, "merge_status": "can_be_merged", "merge_user_id": null, diff --git a/scm/driver/gitlab/webhook.go b/scm/driver/gitlab/webhook.go index cd1ae178e..728663c69 100644 --- a/scm/driver/gitlab/webhook.go +++ b/scm/driver/gitlab/webhook.go @@ -613,7 +613,7 @@ type ( MergeCommitSha string `json:"merge_commit_sha"` MergeError interface{} `json:"merge_error"` MergeParams struct { - ForceRemoveSourceBranch bool `json:"force_remove_source_branch"` + ForceRemoveSourceBranch interface{} `json:"force_remove_source_branch"` } `json:"merge_params"` MergeStatus string `json:"merge_status"` MergeUserID interface{} `json:"merge_user_id"` @@ -698,7 +698,7 @@ type ( MergeCommitSha string `json:"merge_commit_sha"` MergeError interface{} `json:"merge_error"` MergeParams struct { - ForceRemoveSourceBranch bool `json:"force_remove_source_branch"` + ForceRemoveSourceBranch interface{} `json:"force_remove_source_branch"` } `json:"merge_params"` MergeStatus string `json:"merge_status"` MergeUserID interface{} `json:"merge_user_id"`