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
cf85e73e
Commit
cf85e73e
authored
Jun 18, 2019
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Automatic merge of gitlab-org/gitlab-ce master
parents
e926d44e
0eae158c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
46 additions
and
1 deletion
+46
-1
app/services/git/branch_hooks_service.rb
app/services/git/branch_hooks_service.rb
+7
-1
changelogs/unreleased/59257-find-new-branches-harder.yml
changelogs/unreleased/59257-find-new-branches-harder.yml
+5
-0
spec/services/git/branch_hooks_service_spec.rb
spec/services/git/branch_hooks_service_spec.rb
+34
-0
No files found.
app/services/git/branch_hooks_service.rb
View file @
cf85e73e
...
...
@@ -105,8 +105,14 @@ module Git
CreateGpgSignatureWorker
.
perform_async
(
signable
,
project
.
id
)
end
# It's not sufficient to just check for a blank SHA as it's possible for the
# branch to be pushed, but for the `post-receive` hook to never run:
# https://gitlab.com/gitlab-org/gitlab-ce/issues/59257
def
creating_branch?
Gitlab
::
Git
.
blank_ref?
(
params
[
:oldrev
])
strong_memoize
(
:creating_branch
)
do
Gitlab
::
Git
.
blank_ref?
(
params
[
:oldrev
])
||
!
project
.
repository
.
branch_exists?
(
branch_name
)
end
end
def
updating_branch?
...
...
changelogs/unreleased/59257-find-new-branches-harder.yml
0 → 100644
View file @
cf85e73e
---
title
:
Look for new branches more carefully
merge_request
:
29761
author
:
type
:
fixed
spec/services/git/branch_hooks_service_spec.rb
View file @
cf85e73e
...
...
@@ -344,4 +344,38 @@ describe Git::BranchHooksService do
end
end
end
describe
'New branch detection'
do
let
(
:branch
)
{
'fix'
}
context
'oldrev is the blank SHA'
do
let
(
:oldrev
)
{
Gitlab
::
Git
::
BLANK_SHA
}
it
'is treated as a new branch'
do
expect
(
service
).
to
receive
(
:branch_create_hooks
)
service
.
execute
end
end
context
'oldrev is set'
do
context
'Gitaly does not know about the branch'
do
it
'is treated as a new branch'
do
allow
(
project
.
repository
).
to
receive
(
:branch_names
)
{
[]
}
expect
(
service
).
to
receive
(
:branch_create_hooks
)
service
.
execute
end
end
context
'Gitaly knows about the branch'
do
it
'is not treated as a new branch'
do
expect
(
service
).
not_to
receive
(
:branch_create_hooks
)
service
.
execute
end
end
end
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