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
afe86792
Commit
afe86792
authored
Aug 09, 2019
by
Stan Hu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename branches_exist? -> includes_branches?
parent
d96c24d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
16 additions
and
13 deletions
+16
-13
app/workers/post_receive.rb
app/workers/post_receive.rb
+1
-1
lib/gitlab/git_post_receive.rb
lib/gitlab/git_post_receive.rb
+3
-5
spec/lib/gitlab/git_post_receive_spec.rb
spec/lib/gitlab/git_post_receive_spec.rb
+4
-4
spec/workers/post_receive_spec.rb
spec/workers/post_receive_spec.rb
+8
-3
No files found.
app/workers/post_receive.rb
View file @
afe86792
...
...
@@ -43,7 +43,7 @@ class PostReceive
return
false
unless
user
# Expire the branches cache so we have updated data for this push
post_received
.
project
.
repository
.
expire_branches_cache
if
post_received
.
branches_exist
?
post_received
.
project
.
repository
.
expire_branches_cache
if
post_received
.
includes_branches
?
post_received
.
enum_for
(
:changes_refs
).
with_index
do
|
(
oldrev
,
newrev
,
ref
),
index
|
service_klass
=
...
...
lib/gitlab/git_post_receive.rb
View file @
afe86792
...
...
@@ -27,12 +27,10 @@ module Gitlab
end
end
def
branches_exist
?
changes_refs
do
|
_oldrev
,
_newrev
,
ref
|
return
true
if
Gitlab
::
Git
.
branch_ref?
(
ref
)
# rubocop:disable Cop/AvoidReturnFromBlocks
def
includes_branches
?
enum_for
(
:changes_refs
).
any?
do
|
_oldrev
,
_newrev
,
ref
|
Gitlab
::
Git
.
branch_ref?
(
ref
)
end
false
end
private
...
...
spec/lib/gitlab/git_post_receive_spec.rb
View file @
afe86792
...
...
@@ -7,7 +7,7 @@ describe ::Gitlab::GitPostReceive do
subject
{
described_class
.
new
(
project
,
"project-
#{
project
.
id
}
"
,
changes
.
dup
,
{})
}
describe
'#
branches_exist
?'
do
describe
'#
includes_branches
?'
do
context
'with no branches'
do
let
(
:changes
)
do
<<~
EOF
...
...
@@ -18,7 +18,7 @@ describe ::Gitlab::GitPostReceive do
end
it
'returns false'
do
expect
(
subject
.
branches_exist
?
).
to
be_falsey
expect
(
subject
.
includes_branches
?
).
to
be_falsey
end
end
...
...
@@ -32,7 +32,7 @@ describe ::Gitlab::GitPostReceive do
end
it
'returns true'
do
expect
(
subject
.
branches_exist
?
).
to
be_truthy
expect
(
subject
.
includes_branches
?
).
to
be_truthy
end
end
...
...
@@ -45,7 +45,7 @@ describe ::Gitlab::GitPostReceive do
end
it
'returns false'
do
expect
(
subject
.
branches_exist
?
).
to
be_falsey
expect
(
subject
.
includes_branches
?
).
to
be_falsey
end
end
end
...
...
spec/workers/post_receive_spec.rb
View file @
afe86792
...
...
@@ -61,16 +61,21 @@ describe PostReceive do
end
context
"branches"
do
let
(
:changes
)
{
'123456 789012 refs/heads/tést'
}
let
(
:changes
)
do
<<~
EOF
'123456 789012 refs/heads/tést1'
'123456 789012 refs/heads/tést2'
EOF
end
it
'expires the branches cache'
do
expect
(
project
.
repository
).
to
receive
(
:expire_branches_cache
)
expect
(
project
.
repository
).
to
receive
(
:expire_branches_cache
)
.
once
described_class
.
new
.
perform
(
gl_repository
,
key_id
,
base64_changes
)
end
it
'calls Git::BranchPushService'
do
expect_
next
_instance_of
(
Git
::
BranchPushService
)
do
|
service
|
expect_
any
_instance_of
(
Git
::
BranchPushService
)
do
|
service
|
expect
(
service
).
to
receive
(
:execute
).
and_return
(
true
)
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