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
iv
gitlab-ce
Commits
87cf5b70
Commit
87cf5b70
authored
Sep 26, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix GitPush service
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
1302dc8f
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
26 deletions
+31
-26
app/services/git_push_service.rb
app/services/git_push_service.rb
+31
-26
No files found.
app/services/git_push_service.rb
View file @
87cf5b70
...
@@ -17,27 +17,17 @@ class GitPushService
...
@@ -17,27 +17,17 @@ class GitPushService
def
execute
(
project
,
user
,
oldrev
,
newrev
,
ref
)
def
execute
(
project
,
user
,
oldrev
,
newrev
,
ref
)
@project
,
@user
=
project
,
user
@project
,
@user
=
project
,
user
# Collect data for this git push
@push_commits
=
project
.
repository
.
commits_between
(
oldrev
,
newrev
)
@push_data
=
post_receive_data
(
oldrev
,
newrev
,
ref
)
create_push_event
project
.
ensure_satellite_exists
project
.
ensure_satellite_exists
project
.
repository
.
expire_cache
project
.
repository
.
expire_cache
project
.
update_repository_size
project
.
update_repository_size
if
push_to_branch?
(
ref
)
if
push_to_existing_branch?
(
ref
,
oldrev
)
if
push_to_existing_branch?
(
ref
,
oldrev
)
# Collect data for this git push
@push_commits
=
project
.
repository
.
commits_between
(
oldrev
,
newrev
)
project
.
update_merge_requests
(
oldrev
,
newrev
,
ref
,
@user
)
project
.
update_merge_requests
(
oldrev
,
newrev
,
ref
,
@user
)
process_commit_messages
(
ref
)
process_commit_messages
(
ref
)
end
elsif
push_to_new_branch?
(
ref
,
oldrev
)
if
push_to_branch?
(
ref
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
)
end
if
push_to_new_branch?
(
ref
,
oldrev
)
# Re-find the pushed commits.
# Re-find the pushed commits.
if
is_default_branch?
(
ref
)
if
is_default_branch?
(
ref
)
# Initial push to the default branch. Take the full history of that branch as "newly pushed".
# Initial push to the default branch. Take the full history of that branch as "newly pushed".
...
@@ -50,6 +40,15 @@ class GitPushService
...
@@ -50,6 +40,15 @@ class GitPushService
end
end
process_commit_messages
(
ref
)
process_commit_messages
(
ref
)
elsif
push_remove_branch_branch?
(
ref
,
newrev
)
@push_commits
=
[]
end
@push_data
=
post_receive_data
(
oldrev
,
newrev
,
ref
)
create_push_event
(
@push_data
)
project
.
execute_hooks
(
@push_data
.
dup
,
:push_hooks
)
project
.
execute_services
(
@push_data
.
dup
)
end
end
end
end
...
@@ -65,7 +64,7 @@ class GitPushService
...
@@ -65,7 +64,7 @@ class GitPushService
protected
protected
def
create_push_event
def
create_push_event
(
push_data
)
Event
.
create!
(
Event
.
create!
(
project:
project
,
project:
project
,
action:
Event
::
PUSHED
,
action:
Event
::
PUSHED
,
...
@@ -179,6 +178,12 @@ class GitPushService
...
@@ -179,6 +178,12 @@ class GitPushService
ref_parts
[
1
]
=~
/heads/
&&
oldrev
==
"0000000000000000000000000000000000000000"
ref_parts
[
1
]
=~
/heads/
&&
oldrev
==
"0000000000000000000000000000000000000000"
end
end
def
push_remove_branch?
ref
,
newrev
ref_parts
=
ref
.
split
(
'/'
)
ref_parts
[
1
]
=~
/heads/
&&
newrev
==
"0000000000000000000000000000000000000000"
end
def
push_to_branch?
ref
def
push_to_branch?
ref
ref
=~
/refs\/heads/
ref
=~
/refs\/heads/
end
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