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
Léo-Paul Géneau
gitlab-ce
Commits
84d28209
Commit
84d28209
authored
Mar 13, 2015
by
Douwe Maan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use PushDataBuilder where applicable.
parent
4e49f21b
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
27 deletions
+22
-27
app/services/create_branch_service.rb
app/services/create_branch_service.rb
+11
-3
app/services/create_tag_service.rb
app/services/create_tag_service.rb
+2
-2
app/services/delete_branch_service.rb
app/services/delete_branch_service.rb
+9
-2
app/services/event_create_service.rb
app/services/event_create_service.rb
+0
-20
No files found.
app/services/create_branch_service.rb
View file @
84d28209
...
...
@@ -17,10 +17,13 @@ class CreateBranchService < BaseService
new_branch
=
repository
.
find_branch
(
branch_name
)
if
new_branch
EventCreateService
.
new
.
push_ref
(
project
,
current_user
,
new_branch
,
'add'
)
return
success
(
new_branch
)
push_data
=
build_push_data
(
project
,
current_user
,
new_branch
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
success
(
new_branch
)
else
return
error
(
'Invalid reference name'
)
error
(
'Invalid reference name'
)
end
end
...
...
@@ -29,4 +32,9 @@ class CreateBranchService < BaseService
out
[
:branch
]
=
branch
out
end
def
build_push_data
(
project
,
user
,
branch
)
Gitlab
::
PushDataBuilder
.
build
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
branch
.
target
,
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
branch
.
name
}
"
,
[])
end
end
app/services/create_tag_service.rb
View file @
84d28209
...
...
@@ -21,9 +21,9 @@ class CreateTagService < BaseService
new_tag
=
repository
.
find_tag
(
tag_name
)
if
new_tag
EventCreateService
.
new
.
push_ref
(
project
,
current_user
,
new_tag
,
'add'
,
Gitlab
::
Git
::
TAG_REF_PREFIX
)
push_data
=
create_push_data
(
project
,
current_user
,
new_tag
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
project
.
execute_hooks
(
push_data
.
dup
,
:tag_push_hooks
)
project
.
execute_services
(
push_data
.
dup
,
:tag_push_hooks
)
...
...
app/services/delete_branch_service.rb
View file @
84d28209
...
...
@@ -25,10 +25,12 @@ class DeleteBranchService < BaseService
end
if
repository
.
rm_branch
(
branch_name
)
EventCreateService
.
new
.
push_ref
(
project
,
current_user
,
branch
,
'rm'
)
push_data
=
build_push_data
(
branch
)
EventCreateService
.
new
.
push
(
project
,
current_user
,
push_data
)
success
(
'Branch was removed'
)
else
return
error
(
'Failed to remove branch'
)
error
(
'Failed to remove branch'
)
end
end
...
...
@@ -43,4 +45,9 @@ class DeleteBranchService < BaseService
out
[
:message
]
=
message
out
end
def
build_push_data
(
branch
)
Gitlab
::
PushDataBuilder
.
build
(
project
,
current_user
,
branch
.
target
,
Gitlab
::
Git
::
BLANK_SHA
,
"
#{
Gitlab
::
Git
::
BRANCH_REF_PREFIX
}#{
branch
.
name
}
"
,
[])
end
end
app/services/event_create_service.rb
View file @
84d28209
...
...
@@ -62,26 +62,6 @@ class EventCreateService
create_event
(
project
,
current_user
,
Event
::
CREATED
)
end
def
push_ref
(
project
,
current_user
,
ref
,
action
=
'add'
,
prefix
=
Gitlab
::
Git
::
BRANCH_REF_PREFIX
)
commit
=
project
.
repository
.
commit
(
ref
.
target
)
if
action
.
to_s
==
'add'
before
=
Gitlab
::
Git
::
BLANK_SHA
after
=
commit
.
id
else
before
=
commit
.
id
after
=
Gitlab
::
Git
::
BLANK_SHA
end
data
=
{
ref:
"
#{
prefix
}#{
ref
.
name
}
"
,
before:
before
,
after:
after
}
push
(
project
,
current_user
,
data
)
end
def
push
(
project
,
current_user
,
push_data
)
create_event
(
project
,
current_user
,
Event
::
PUSHED
,
data:
push_data
)
end
...
...
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