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
6be56fc8
Commit
6be56fc8
authored
Aug 22, 2018
by
GitLab Bot
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-08-22
parents
e02f4141
8b85d6bc
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
94 additions
and
13 deletions
+94
-13
app/services/git_push_service.rb
app/services/git_push_service.rb
+10
-4
changelogs/unreleased/sh-fix-broken-ldap-clones.yml
changelogs/unreleased/sh-fix-broken-ldap-clones.yml
+5
-0
changelogs/unreleased/sh-fix-wrong-commit-count-in-push.yml
changelogs/unreleased/sh-fix-wrong-commit-count-in-push.yml
+5
-0
lib/gitlab/auth/o_auth/provider.rb
lib/gitlab/auth/o_auth/provider.rb
+1
-0
spec/lib/gitlab/auth/o_auth/provider_spec.rb
spec/lib/gitlab/auth/o_auth/provider_spec.rb
+42
-0
spec/services/git_push_service_spec.rb
spec/services/git_push_service_spec.rb
+31
-9
No files found.
app/services/git_push_service.rb
View file @
6be56fc8
...
...
@@ -164,7 +164,7 @@ class GitPushService < BaseService
end
def
process_default_branch
offset
=
[
push_commits_count
-
PROCESS_COMMIT_LIMIT
,
0
].
max
offset
=
[
push_commits_count
_for_ref
-
PROCESS_COMMIT_LIMIT
,
0
].
max
@push_commits
=
project
.
repository
.
commits
(
params
[
:newrev
],
offset:
offset
,
limit:
PROCESS_COMMIT_LIMIT
)
project
.
after_create_default_branch
...
...
@@ -178,7 +178,7 @@ class GitPushService < BaseService
params
[
:newrev
],
params
[
:ref
],
@push_commits
,
commits_count:
push_
commits_count
)
commits_count:
commits_count
)
end
def
push_to_existing_branch?
...
...
@@ -219,8 +219,14 @@ class GitPushService < BaseService
end
end
def
push_commits_count
strong_memoize
(
:push_commits_count
)
do
def
commits_count
return
push_commits_count_for_ref
if
default_branch?
&&
push_to_new_branch?
Array
(
@push_commits
).
size
end
def
push_commits_count_for_ref
strong_memoize
(
:push_commits_count_for_ref
)
do
project
.
repository
.
commit_count_for_ref
(
params
[
:ref
])
end
end
...
...
changelogs/unreleased/sh-fix-broken-ldap-clones.yml
0 → 100644
View file @
6be56fc8
---
title
:
Fix broken Git over HTTP clones with LDAP users
merge_request
:
21352
author
:
type
:
fixed
changelogs/unreleased/sh-fix-wrong-commit-count-in-push.yml
0 → 100644
View file @
6be56fc8
---
title
:
Fix wrong commit count in push event payload
merge_request
:
21338
author
:
type
:
fixed
lib/gitlab/auth/o_auth/provider.rb
View file @
6be56fc8
...
...
@@ -29,6 +29,7 @@ module Gitlab
def
self
.
enabled?
(
name
)
return
true
if
name
==
'database'
return
true
if
self
.
ldap_provider?
(
name
)
&&
providers
.
include?
(
name
.
to_sym
)
Gitlab
::
Auth
.
omniauth_enabled?
&&
providers
.
include?
(
name
.
to_sym
)
end
...
...
spec/lib/gitlab/auth/o_auth/provider_spec.rb
View file @
6be56fc8
require
'spec_helper'
describe
Gitlab
::
Auth
::
OAuth
::
Provider
do
describe
'.enabled?'
do
before
do
allow
(
described_class
).
to
receive
(
:providers
).
and_return
([
:ldapmain
,
:google_oauth2
])
end
context
'when OmniAuth is disabled'
do
before
do
allow
(
Gitlab
::
Auth
).
to
receive
(
:omniauth_enabled?
).
and_return
(
false
)
end
it
'allows database auth'
do
expect
(
described_class
.
enabled?
(
'database'
)).
to
be_truthy
end
it
'allows LDAP auth'
do
expect
(
described_class
.
enabled?
(
'ldapmain'
)).
to
be_truthy
end
it
'does not allow other OmniAuth providers'
do
expect
(
described_class
.
enabled?
(
'google_oauth2'
)).
to
be_falsey
end
end
context
'when OmniAuth is enabled'
do
before
do
allow
(
Gitlab
::
Auth
).
to
receive
(
:omniauth_enabled?
).
and_return
(
true
)
end
it
'allows database auth'
do
expect
(
described_class
.
enabled?
(
'database'
)).
to
be_truthy
end
it
'allows LDAP auth'
do
expect
(
described_class
.
enabled?
(
'ldapmain'
)).
to
be_truthy
end
it
'allows other OmniAuth providers'
do
expect
(
described_class
.
enabled?
(
'google_oauth2'
)).
to
be_truthy
end
end
end
describe
'#config_for'
do
context
'for an LDAP provider'
do
context
'when the provider exists'
do
...
...
spec/services/git_push_service_spec.rb
View file @
6be56fc8
...
...
@@ -226,16 +226,37 @@ describe GitPushService do
end
describe
"Push Event"
do
let!
(
:push_data
)
{
push_data_from_service
(
project
,
user
,
oldrev
,
newrev
,
ref
)
}
let
(
:event
)
{
Event
.
find_by_action
(
Event
::
PUSHED
)
}
context
"with an existing branch"
do
let!
(
:push_data
)
{
push_data_from_service
(
project
,
user
,
oldrev
,
newrev
,
ref
)
}
let
(
:event
)
{
Event
.
find_by_action
(
Event
::
PUSHED
)
}
it
{
expect
(
event
).
to
be_an_instance_of
(
PushEvent
)
}
it
{
expect
(
event
.
project
).
to
eq
(
project
)
}
it
{
expect
(
event
.
action
).
to
eq
(
Event
::
PUSHED
)
}
it
{
expect
(
event
.
push_event_payload
).
to
be_an_instance_of
(
PushEventPayload
)
}
it
{
expect
(
event
.
push_event_payload
.
commit_from
).
to
eq
(
oldrev
)
}
it
{
expect
(
event
.
push_event_payload
.
commit_to
).
to
eq
(
newrev
)
}
it
{
expect
(
event
.
push_event_payload
.
ref
).
to
eq
(
'master'
)
}
it
'generates a push event with one commit'
do
expect
(
event
).
to
be_an_instance_of
(
PushEvent
)
expect
(
event
.
project
).
to
eq
(
project
)
expect
(
event
.
action
).
to
eq
(
Event
::
PUSHED
)
expect
(
event
.
push_event_payload
).
to
be_an_instance_of
(
PushEventPayload
)
expect
(
event
.
push_event_payload
.
commit_from
).
to
eq
(
oldrev
)
expect
(
event
.
push_event_payload
.
commit_to
).
to
eq
(
newrev
)
expect
(
event
.
push_event_payload
.
ref
).
to
eq
(
'master'
)
expect
(
event
.
push_event_payload
.
commit_count
).
to
eq
(
1
)
end
end
context
"with a new branch"
do
let!
(
:new_branch_data
)
{
push_data_from_service
(
project
,
user
,
Gitlab
::
Git
::
BLANK_SHA
,
newrev
,
ref
)
}
let
(
:event
)
{
Event
.
find_by_action
(
Event
::
PUSHED
)
}
it
'generates a push event with more than one commit'
do
expect
(
event
).
to
be_an_instance_of
(
PushEvent
)
expect
(
event
.
project
).
to
eq
(
project
)
expect
(
event
.
action
).
to
eq
(
Event
::
PUSHED
)
expect
(
event
.
push_event_payload
).
to
be_an_instance_of
(
PushEventPayload
)
expect
(
event
.
push_event_payload
.
commit_from
).
to
be_nil
expect
(
event
.
push_event_payload
.
commit_to
).
to
eq
(
newrev
)
expect
(
event
.
push_event_payload
.
ref
).
to
eq
(
'master'
)
expect
(
event
.
push_event_payload
.
commit_count
).
to
be
>
1
end
end
context
"Updates merge requests"
do
it
"when pushing a new branch for the first time"
do
...
...
@@ -246,6 +267,7 @@ describe GitPushService do
end
describe
'system hooks'
do
let!
(
:push_data
)
{
push_data_from_service
(
project
,
user
,
oldrev
,
newrev
,
ref
)
}
let
(
:system_hooks_service
)
{
SystemHooksService
.
new
}
it
"sends a system hook after pushing a branch"
do
...
...
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