Skip to content

Commit

Permalink
RELTEC-11865: updated api, added new fields: "branchNameRegex" and "c…
Browse files Browse the repository at this point in the history
…ommitMessageRegex", removed obsolete "pipelineTrigger" flag
  • Loading branch information
mplushnikov committed Jun 19, 2024
1 parent e2371a0 commit 2a2b224
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 15 deletions.
4 changes: 4 additions & 0 deletions api/generated_model_repository_configuration_dto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 0 additions & 2 deletions api/generated_model_repository_configuration_webhooks_dto.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions api/openapi-v3-spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -2872,6 +2872,8 @@
"url": "ssh://git@bitbucket.some-organisation.com:7999/UNICORNS/unicorn-finder-service-deployment.git",
"mainline": "main",
"configuration": {
"branchNameRegex": "(testing_[^_-]+_[^-]+$|development.*|production.*|versioncheck.*|renovate.*)",
"commitMessageRegex": "(([A-Z][A-Z_0-9]+-[0-9]+)|(Ticket#[0-9]{16})[^0-9]|((SCTASK|INC|RITM|CHG)[0-9]{7}))(.|\\n)*",
"commitMessageType": "DEFAULT",
"requireIssue": true,
"requireSuccessfulBuilds": 1,
Expand All @@ -2883,7 +2885,6 @@
}
],
"webhooks": {
"pipelineTrigger": true,
"predefined": [
"jenkinsPipeline"
],
Expand Down Expand Up @@ -2958,6 +2959,14 @@
}
}
},
"branchNameRegex": {
"type": "string",
"description": "Use an explicit branch name regex."
},
"commitMessageRegex": {
"type": "string",
"description": "Use an explicit commit message regex."
},
"commitMessageType": {
"type": "string",
"description": "Adds a corresponding commit message regex.",
Expand Down Expand Up @@ -3125,10 +3134,6 @@
"type": "object",
"description": "Webhooks configured to the repository.",
"properties": {
"pipelineTrigger": {
"type": "boolean",
"description": "Default pipeline trigger webhook."
},
"predefined": {
"type": "array",
"description": "List of predefined webhooks",
Expand Down
5 changes: 3 additions & 2 deletions internal/service/repositories/repositories.go
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,8 @@ func patchConfiguration(patch *openapi.RepositoryConfigurationDto, original *ope
}
return &openapi.RepositoryConfigurationDto{
AccessKeys: patchAccessKeys(patch.AccessKeys, original.AccessKeys),
BranchNameRegex: patchStringPtr(patch.BranchNameRegex, original.BranchNameRegex),
CommitMessageRegex: patchStringPtr(patch.CommitMessageRegex, original.CommitMessageRegex),
CommitMessageType: patchStringPtr(patch.CommitMessageType, original.CommitMessageType),
RequireIssue: patchPtr[bool](patch.RequireIssue, original.RequireIssue),
RequireSuccessfulBuilds: patchPtr[int32](patch.RequireSuccessfulBuilds, original.RequireSuccessfulBuilds),
Expand Down Expand Up @@ -516,8 +518,7 @@ func patchWebhooks(patch *openapi.RepositoryConfigurationWebhooksDto, original *
original = &openapi.RepositoryConfigurationWebhooksDto{}
}
return &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: patchPtr[bool](patch.PipelineTrigger, original.PipelineTrigger),
Additional: patchAdditionalWebhooks(patch.Additional, original.Additional),
Additional: patchAdditionalWebhooks(patch.Additional, original.Additional),
}
} else {
return original
Expand Down
10 changes: 5 additions & 5 deletions internal/service/repositories/repositories_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func createRepositoryDto() openapi.RepositoryDto {
RequireIssue: ptr(false),
RequireSuccessfulBuilds: i(1),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "webhookname",
Expand Down Expand Up @@ -115,11 +114,12 @@ func TestPatchRepository_ReplaceAll(t *testing.T) {
Permission: ptr("REPO_READ"),
},
},
BranchNameRegex: ptr("(testing_[^_-]+_[^-]+$)"),
CommitMessageRegex: ptr("(([A-Z][A-Z_0-9]+-[0-9]+))(.|\\n)*"),
CommitMessageType: ptr("DEFAULT"),
RequireIssue: ptr(true),
RequireSuccessfulBuilds: i(2),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "newwebhookname",
Expand Down Expand Up @@ -151,11 +151,12 @@ func TestPatchRepository_ReplaceAll(t *testing.T) {
Permission: ptr("REPO_READ"),
},
},
BranchNameRegex: ptr("(testing_[^_-]+_[^-]+$)"),
CommitMessageRegex: ptr("(([A-Z][A-Z_0-9]+-[0-9]+))(.|\\n)*"),
CommitMessageType: ptr("DEFAULT"),
RequireIssue: ptr(true),
RequireSuccessfulBuilds: i(2),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "newwebhookname",
Expand Down Expand Up @@ -210,8 +211,7 @@ func TestPatchRepository_ClearFields(t *testing.T) {
RequireIssue: ptr(false),
RequireSuccessfulBuilds: i(1),
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: ptr(false),
Additional: nil,
Additional: nil,
},
Approvers: nil,
DefaultReviewers: nil,
Expand Down
1 change: 0 additions & 1 deletion test/acceptance/util_dtos_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,6 @@ func tstRepository() openapi.RepositoryDto {
RequireSuccessfulBuilds: pi(1),
RequireConditions: &map[string]openapi.ConditionReferenceDto{"snyk-key": {RefMatcher: "master"}},
Webhooks: &openapi.RepositoryConfigurationWebhooksDto{
PipelineTrigger: pb(false),
Additional: []openapi.RepositoryConfigurationWebhookDto{
{
Name: "webhookname",
Expand Down

0 comments on commit 2a2b224

Please sign in to comment.