Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
1ddf2cb8
Commit
1ddf2cb8
authored
Nov 12, 2021
by
Luke Duncalfe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Namespace and rename ServicePushDataValidations
https://gitlab.com/gitlab-org/gitlab/-/issues/330670#note_575341780
parent
3f51bfe0
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
46 additions
and
45 deletions
+46
-45
app/models/concerns/integrations/push_data_validations.rb
app/models/concerns/integrations/push_data_validations.rb
+44
-0
app/models/concerns/service_push_data_validations.rb
app/models/concerns/service_push_data_validations.rb
+0
-43
app/models/integrations/drone_ci.rb
app/models/integrations/drone_ci.rb
+1
-1
app/models/integrations/teamcity.rb
app/models/integrations/teamcity.rb
+1
-1
No files found.
app/models/concerns/integrations/push_data_validations.rb
0 → 100644
View file @
1ddf2cb8
# frozen_string_literal: true
# This concern is used by registered integrations such as Integrations::TeamCity and
# Integrations::DroneCi and adds methods to perform validations on the received
# data.
module
Integrations
module
PushDataValidations
extend
ActiveSupport
::
Concern
def
merge_request_valid?
(
data
)
data
.
dig
(
:object_attributes
,
:state
)
==
'opened'
&&
merge_request_unchecked?
(
data
)
end
def
push_valid?
(
data
)
data
[
:total_commits_count
]
>
0
&&
!
branch_removed?
(
data
)
&&
# prefer merge request trigger over push to avoid double builds
!
opened_merge_requests?
(
data
)
end
def
tag_push_valid?
(
data
)
data
[
:total_commits_count
]
>
0
&&
!
branch_removed?
(
data
)
end
private
def
branch_removed?
(
data
)
Gitlab
::
Git
.
blank_ref?
(
data
[
:after
])
end
def
opened_merge_requests?
(
data
)
project
.
merge_requests
.
opened
.
from_project
(
project
)
.
from_source_branches
(
Gitlab
::
Git
.
ref_name
(
data
[
:ref
]))
.
exists?
end
def
merge_request_unchecked?
(
data
)
MergeRequest
.
state_machines
[
:merge_status
]
.
check_state?
(
data
.
dig
(
:object_attributes
,
:merge_status
))
end
end
end
app/models/concerns/service_push_data_validations.rb
deleted
100644 → 0
View file @
3f51bfe0
# frozen_string_literal: true
# This concern is used by registered integrations such as Integrations::TeamCity and
# Integrations::DroneCi and adds methods to perform validations on the received
# data.
module
ServicePushDataValidations
extend
ActiveSupport
::
Concern
def
merge_request_valid?
(
data
)
data
.
dig
(
:object_attributes
,
:state
)
==
'opened'
&&
merge_request_unchecked?
(
data
)
end
def
push_valid?
(
data
)
data
[
:total_commits_count
]
>
0
&&
!
branch_removed?
(
data
)
&&
# prefer merge request trigger over push to avoid double builds
!
opened_merge_requests?
(
data
)
end
def
tag_push_valid?
(
data
)
data
[
:total_commits_count
]
>
0
&&
!
branch_removed?
(
data
)
end
private
def
branch_removed?
(
data
)
Gitlab
::
Git
.
blank_ref?
(
data
[
:after
])
end
def
opened_merge_requests?
(
data
)
project
.
merge_requests
.
opened
.
from_project
(
project
)
.
from_source_branches
(
Gitlab
::
Git
.
ref_name
(
data
[
:ref
]))
.
exists?
end
def
merge_request_unchecked?
(
data
)
MergeRequest
.
state_machines
[
:merge_status
]
.
check_state?
(
data
.
dig
(
:object_attributes
,
:merge_status
))
end
end
app/models/integrations/drone_ci.rb
View file @
1ddf2cb8
...
@@ -3,8 +3,8 @@
...
@@ -3,8 +3,8 @@
module
Integrations
module
Integrations
class
DroneCi
<
BaseCi
class
DroneCi
<
BaseCi
include
HasWebHook
include
HasWebHook
include
PushDataValidations
include
ReactivelyCached
include
ReactivelyCached
include
ServicePushDataValidations
extend
Gitlab
::
Utils
::
Override
extend
Gitlab
::
Utils
::
Override
prop_accessor
:drone_url
,
:token
prop_accessor
:drone_url
,
:token
...
...
app/models/integrations/teamcity.rb
View file @
1ddf2cb8
...
@@ -2,8 +2,8 @@
...
@@ -2,8 +2,8 @@
module
Integrations
module
Integrations
class
Teamcity
<
BaseCi
class
Teamcity
<
BaseCi
include
PushDataValidations
include
ReactivelyCached
include
ReactivelyCached
include
ServicePushDataValidations
prop_accessor
:teamcity_url
,
:build_type
,
:username
,
:password
prop_accessor
:teamcity_url
,
:build_type
,
:username
,
:password
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment