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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
ec0daedb
Commit
ec0daedb
authored
Nov 11, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add service that runs after branch removed hooks
parent
be3d74e0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
6 deletions
+45
-6
app/services/after_branch_delete_service.rb
app/services/after_branch_delete_service.rb
+23
-0
app/services/delete_branch_service.rb
app/services/delete_branch_service.rb
+9
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+13
-6
No files found.
app/services/after_branch_delete_service.rb
0 → 100644
View file @
ec0daedb
require_relative
'base_service'
##
# Branch can be deleted either by DeleteBranchService
# or by GitPushService.
#
class
AfterBranchDeleteService
<
BaseService
attr_reader
:branch_name
def
execute
(
branch_name
)
@branch_name
=
branch_name
stop_environments
end
private
def
stop_environments
Ci
::
StopEnvironmentService
.
new
(
project
,
current_user
)
.
execute
(
branch_name
)
end
end
app/services/delete_branch_service.rb
View file @
ec0daedb
...
...
@@ -22,6 +22,7 @@ class DeleteBranchService < BaseService
end
if
repository
.
rm_branch
(
current_user
,
branch_name
)
execute_after_branch_delete_hooks
(
branch_name
)
success
(
'Branch was removed'
)
else
error
(
'Failed to remove branch'
)
...
...
@@ -47,4 +48,12 @@ class DeleteBranchService < BaseService
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
branch
.
name
}
"
,
[])
end
private
def
execute_after_branch_delete_hooks
(
branch_name
)
AfterBranchDeleteService
.
new
(
project
,
current_user
)
.
execute
(
branch_name
)
end
end
app/services/git_push_service.rb
View file @
ec0daedb
...
...
@@ -49,10 +49,7 @@ class GitPushService < BaseService
update_gitattributes
if
is_default_branch?
end
# Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change.
update_merge_requests
execute_related_hooks
perform_housekeeping
end
...
...
@@ -62,14 +59,24 @@ class GitPushService < BaseService
protected
def
update_merge_requests
UpdateMergeRequestsWorker
.
perform_async
(
@project
.
id
,
current_user
.
id
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
])
def
execute_related_hooks
# Update merge requests that may be affected by this push. A new branch
# could cause the last commit of a merge request to change.
#
UpdateMergeRequestsWorker
.
perform_async
(
@project
.
id
,
current_user
.
id
,
params
[
:oldrev
],
params
[
:newrev
],
params
[
:ref
])
EventCreateService
.
new
.
push
(
@project
,
current_user
,
build_push_data
)
@project
.
execute_hooks
(
build_push_data
.
dup
,
:push_hooks
)
@project
.
execute_services
(
build_push_data
.
dup
,
:push_hooks
)
Ci
::
CreatePipelineService
.
new
(
@project
,
current_user
,
build_push_data
).
execute
ProjectCacheWorker
.
perform_async
(
@project
.
id
)
if
push_remove_branch?
AfterBranchDeleteService
.
new
(
project
,
current_user
)
.
execute
(
branch_name
)
end
end
def
perform_housekeeping
...
...
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