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
f6eb5bf6
Commit
f6eb5bf6
authored
Oct 08, 2019
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'com-code-revert' into 'master'
Revert com code segregation See merge request gitlab-org/gitlab!18212
parents
a674a8a0
990f2779
Changes
12
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
12 additions
and
137 deletions
+12
-137
.dockerignore
.dockerignore
+0
-1
com/lib/com/gitlab/patch/draw_route.rb
com/lib/com/gitlab/patch/draw_route.rb
+0
-16
com/spec/lib/gitlab/patch/draw_route_spec.rb
com/spec/lib/gitlab/patch/draw_route_spec.rb
+0
-25
config/application.rb
config/application.rb
+0
-10
config/initializers/0_inject_com_module.rb
config/initializers/0_inject_com_module.rb
+0
-26
config/light_settings.rb
config/light_settings.rb
+0
-32
lib/gitlab.rb
lib/gitlab.rb
+7
-6
lib/gitlab/patch/draw_route.rb
lib/gitlab/patch/draw_route.rb
+1
-6
qa/Dockerfile
qa/Dockerfile
+0
-2
spec/com_spec_helper.rb
spec/com_spec_helper.rb
+0
-3
spec/fast_spec_helper.rb
spec/fast_spec_helper.rb
+0
-2
spec/lib/gitlab_spec.rb
spec/lib/gitlab_spec.rb
+4
-8
No files found.
.dockerignore
View file @
f6eb5bf6
...
@@ -3,7 +3,6 @@
...
@@ -3,7 +3,6 @@
# Ignore all folders except qa/, config/initializers and the root of lib/ since
# Ignore all folders except qa/, config/initializers and the root of lib/ since
# the files we need to build the QA image are in these folders.
# the files we need to build the QA image are in these folders.
# Following are the files we need:
# Following are the files we need:
# - ./config/light_settings.rb
# - ./config/initializers/0_inject_enterprise_edition_module.rb
# - ./config/initializers/0_inject_enterprise_edition_module.rb
# - ./ee/app/models/license.rb
# - ./ee/app/models/license.rb
# - ./lib/gitlab.rb
# - ./lib/gitlab.rb
...
...
com/lib/com/gitlab/patch/draw_route.rb
deleted
100644 → 0
View file @
a674a8a0
# frozen_string_literal: true
module
Com
module
Gitlab
module
Patch
module
DrawRoute
extend
::
Gitlab
::
Utils
::
Override
override
:draw_com
def
draw_com
(
routes_name
)
draw_route
(
route_path
(
"com/config/routes/
#{
routes_name
}
.rb"
))
end
end
end
end
end
com/spec/lib/gitlab/patch/draw_route_spec.rb
deleted
100644 → 0
View file @
a674a8a0
# frozen_string_literal: true
require
'fast_spec_helper'
require
'com_spec_helper'
describe
Gitlab
::
Patch
::
DrawRoute
do
subject
do
Class
.
new
do
include
Gitlab
::
Patch
::
DrawRoute
def
route_path
(
route_name
)
File
.
expand_path
(
"../../../../../
#{
route_name
}
"
,
__dir__
)
end
end
.
new
end
before
do
allow
(
subject
).
to
receive
(
:instance_eval
)
end
it
'raises an error when nothing is drawn'
do
expect
{
subject
.
draw
(
:non_existing
)
}
.
to
raise_error
(
described_class
::
RoutesNotFound
)
end
end
config/application.rb
View file @
f6eb5bf6
...
@@ -22,7 +22,6 @@ module Gitlab
...
@@ -22,7 +22,6 @@ module Gitlab
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/current_settings'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/current_settings'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/read_only'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/read_only'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/basic_health_check'
)
require_dependency
Rails
.
root
.
join
(
'lib/gitlab/middleware/basic_health_check'
)
require_dependency
Rails
.
root
.
join
(
'config/light_settings'
)
# Settings in config/environments/* take precedence over those specified here.
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# Application configuration should go into files in config/initializers
...
@@ -63,15 +62,6 @@ module Gitlab
...
@@ -63,15 +62,6 @@ module Gitlab
config
.
paths
[
'app/views'
].
unshift
"
#{
config
.
root
}
/ee/app/views"
config
.
paths
[
'app/views'
].
unshift
"
#{
config
.
root
}
/ee/app/views"
end
end
if
LightSettings
.
com?
com_paths
=
config
.
eager_load_paths
.
each_with_object
([])
do
|
path
,
memo
|
com_path
=
config
.
root
.
join
(
'com'
,
Pathname
.
new
(
path
).
relative_path_from
(
config
.
root
))
memo
<<
com_path
.
to_s
end
config
.
eager_load_paths
.
push
(
*
com_paths
)
end
# Rake tasks ignore the eager loading settings, so we need to set the
# Rake tasks ignore the eager loading settings, so we need to set the
# autoload paths explicitly
# autoload paths explicitly
config
.
autoload_paths
=
config
.
eager_load_paths
.
dup
config
.
autoload_paths
=
config
.
eager_load_paths
.
dup
...
...
config/initializers/0_inject_com_module.rb
deleted
100644 → 0
View file @
a674a8a0
# frozen_string_literal: true
require
'active_support/inflector'
module
InjectComModule
def
prepend_if_com
(
constant
,
with_descendants:
false
)
return
unless
Gitlab
.
com?
com_module
=
constant
.
constantize
prepend
(
com_module
)
if
with_descendants
descendants
.
each
{
|
descendant
|
descendant
.
prepend
(
com_module
)
}
end
end
def
extend_if_com
(
constant
)
extend
(
constant
.
constantize
)
if
Gitlab
.
com?
end
def
include_if_com
(
constant
)
include
(
constant
.
constantize
)
if
Gitlab
.
com?
end
end
Module
.
prepend
(
InjectComModule
)
config/light_settings.rb
deleted
100644 → 0
View file @
a674a8a0
# frozen_string_literal: true
class
LightSettings
GL_HOST
||=
'gitlab.com'
GL_SUBDOMAIN_REGEX
||=
%r{
\A
[a-z0-9]+
\.
gitlab
\.
com
\z
}
.
freeze
class
<<
self
def
com?
return
Thread
.
current
[
:is_com
]
unless
Thread
.
current
[
:is_com
].
nil?
Thread
.
current
[
:is_com
]
=
host
==
GL_HOST
||
gl_subdomain?
end
private
def
config
YAML
.
safe_load
(
File
.
read
(
settings_path
),
aliases:
true
)[
Rails
.
env
]
end
def
settings_path
Rails
.
root
.
join
(
'config'
,
'gitlab.yml'
)
end
def
host
config
.
dig
(
'gitlab'
,
'host'
)
||
ENV
[
'GITLAB_HOST'
]
||
'localhost'
end
def
gl_subdomain?
GL_SUBDOMAIN_REGEX
===
host
end
end
end
lib/gitlab.rb
View file @
f6eb5bf6
# frozen_string_literal: true
# frozen_string_literal: true
require
'pathname'
require
'pathname'
require_relative
'../config/light_settings'
module
Gitlab
module
Gitlab
def
self
.
root
def
self
.
root
...
@@ -38,18 +37,24 @@ module Gitlab
...
@@ -38,18 +37,24 @@ module Gitlab
COM_URL
=
'https://gitlab.com'
COM_URL
=
'https://gitlab.com'
APP_DIRS_PATTERN
=
%r{^/?(app|config|ee|lib|spec|
\(\w
*
\)
)}
.
freeze
APP_DIRS_PATTERN
=
%r{^/?(app|config|ee|lib|spec|
\(\w
*
\)
)}
.
freeze
SUBDOMAIN_REGEX
=
%r{
\A
https://[a-z0-9]+
\.
gitlab
\.
com
\z
}
.
freeze
VERSION
=
File
.
read
(
root
.
join
(
"VERSION"
)).
strip
.
freeze
VERSION
=
File
.
read
(
root
.
join
(
"VERSION"
)).
strip
.
freeze
INSTALLATION_TYPE
=
File
.
read
(
root
.
join
(
"INSTALLATION_TYPE"
)).
strip
.
freeze
INSTALLATION_TYPE
=
File
.
read
(
root
.
join
(
"INSTALLATION_TYPE"
)).
strip
.
freeze
HTTP_PROXY_ENV_VARS
=
%w(http_proxy https_proxy HTTP_PROXY HTTPS_PROXY)
.
freeze
HTTP_PROXY_ENV_VARS
=
%w(http_proxy https_proxy HTTP_PROXY HTTPS_PROXY)
.
freeze
def
self
.
com?
def
self
.
com?
LightSettings
.
com?
# Check `gl_subdomain?` as well to keep parity with gitlab.com
Gitlab
.
config
.
gitlab
.
url
==
COM_URL
||
gl_subdomain?
end
end
def
self
.
org?
def
self
.
org?
Gitlab
.
config
.
gitlab
.
url
==
'https://dev.gitlab.org'
Gitlab
.
config
.
gitlab
.
url
==
'https://dev.gitlab.org'
end
end
def
self
.
gl_subdomain?
SUBDOMAIN_REGEX
===
Gitlab
.
config
.
gitlab
.
url
end
def
self
.
dev_env_org_or_com?
def
self
.
dev_env_org_or_com?
dev_env_or_com?
||
org?
dev_env_or_com?
||
org?
end
end
...
@@ -74,10 +79,6 @@ module Gitlab
...
@@ -74,10 +79,6 @@ module Gitlab
yield
if
ee?
yield
if
ee?
end
end
def
self
.
com
yield
if
com?
end
def
self
.
http_proxy_env?
def
self
.
http_proxy_env?
HTTP_PROXY_ENV_VARS
.
any?
{
|
name
|
ENV
[
name
]
}
HTTP_PROXY_ENV_VARS
.
any?
{
|
name
|
ENV
[
name
]
}
end
end
...
...
lib/gitlab/patch/draw_route.rb
View file @
f6eb5bf6
...
@@ -6,12 +6,11 @@ module Gitlab
...
@@ -6,12 +6,11 @@ module Gitlab
module
Patch
module
Patch
module
DrawRoute
module
DrawRoute
prepend_if_ee
(
'EE::Gitlab::Patch::DrawRoute'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
prepend_if_ee
(
'EE::Gitlab::Patch::DrawRoute'
)
# rubocop: disable Cop/InjectEnterpriseEditionModule
prepend_if_com
(
'Com::Gitlab::Patch::DrawRoute'
)
RoutesNotFound
=
Class
.
new
(
StandardError
)
RoutesNotFound
=
Class
.
new
(
StandardError
)
def
draw
(
routes_name
)
def
draw
(
routes_name
)
drawn_any
=
draw_ce
(
routes_name
)
|
draw_ee
(
routes_name
)
|
draw_com
(
routes_name
)
drawn_any
=
draw_ce
(
routes_name
)
|
draw_ee
(
routes_name
)
drawn_any
||
raise
(
RoutesNotFound
.
new
(
"Cannot find
#{
routes_name
}
"
))
drawn_any
||
raise
(
RoutesNotFound
.
new
(
"Cannot find
#{
routes_name
}
"
))
end
end
...
@@ -24,10 +23,6 @@ module Gitlab
...
@@ -24,10 +23,6 @@ module Gitlab
true
true
end
end
def
draw_com
(
_
)
false
end
def
route_path
(
routes_name
)
def
route_path
(
routes_name
)
Rails
.
root
.
join
(
routes_name
)
Rails
.
root
.
join
(
routes_name
)
end
end
...
...
qa/Dockerfile
View file @
f6eb5bf6
...
@@ -49,12 +49,10 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
...
@@ -49,12 +49,10 @@ RUN export CLOUD_SDK_REPO="cloud-sdk-$(lsb_release -c -s)" && \
WORKDIR
/home/gitlab/qa
WORKDIR
/home/gitlab/qa
COPY
./qa/Gemfile* /home/gitlab/qa/
COPY
./qa/Gemfile* /home/gitlab/qa/
COPY
./config/light_settings.rb /home/gitlab/config/light_settings.rb
COPY
./config/initializers/0_inject_enterprise_edition_module.rb /home/gitlab/config/initializers/
COPY
./config/initializers/0_inject_enterprise_edition_module.rb /home/gitlab/config/initializers/
# Copy VERSION to ensure the COPY succeeds to copy at least one file since ee/app/models/license.rb isn't present in FOSS
# Copy VERSION to ensure the COPY succeeds to copy at least one file since ee/app/models/license.rb isn't present in FOSS
# The [b] part makes ./ee/app/models/license.r[b] a pattern that is allowed to return no files (which is the case in FOSS)
# The [b] part makes ./ee/app/models/license.r[b] a pattern that is allowed to return no files (which is the case in FOSS)
COPY
VERSION ./ee/app/models/license.r[b] /home/gitlab/ee/app/models/
COPY
VERSION ./ee/app/models/license.r[b] /home/gitlab/ee/app/models/
COPY
./config/light_settings.rb /home/gitlab/config/
COPY
./lib/gitlab.rb /home/gitlab/lib/
COPY
./lib/gitlab.rb /home/gitlab/lib/
COPY
./INSTALLATION_TYPE ./VERSION /home/gitlab/
COPY
./INSTALLATION_TYPE ./VERSION /home/gitlab/
RUN
cd
/home/gitlab/qa/
&&
bundle
install
--jobs
=
$(
nproc
)
--retry
=
3
--quiet
RUN
cd
/home/gitlab/qa/
&&
bundle
install
--jobs
=
$(
nproc
)
--retry
=
3
--quiet
...
...
spec/com_spec_helper.rb
deleted
100644 → 0
View file @
a674a8a0
# frozen_string_literal: true
Settings
.
gitlab
[
:url
]
=
"https://test.gitlab.com"
spec/fast_spec_helper.rb
View file @
f6eb5bf6
...
@@ -7,12 +7,10 @@ ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true'
...
@@ -7,12 +7,10 @@ ENV['IN_MEMORY_APPLICATION_SETTINGS'] = 'true'
require
'active_support/dependencies'
require
'active_support/dependencies'
require_relative
'../config/initializers/0_inject_enterprise_edition_module'
require_relative
'../config/initializers/0_inject_enterprise_edition_module'
require_relative
'../config/initializers/0_inject_com_module'
require_relative
'../config/settings'
require_relative
'../config/settings'
require_relative
'support/rspec'
require_relative
'support/rspec'
require
'active_support/all'
require
'active_support/all'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'ee/lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'ee/lib'
ActiveSupport
::
Dependencies
.
autoload_paths
<<
'com/lib'
ActiveSupport
::
XmlMini
.
backend
=
'Nokogiri'
ActiveSupport
::
XmlMini
.
backend
=
'Nokogiri'
spec/lib/gitlab_spec.rb
View file @
f6eb5bf6
...
@@ -71,30 +71,26 @@ describe Gitlab do
...
@@ -71,30 +71,26 @@ describe Gitlab do
end
end
describe
'.com?'
do
describe
'.com?'
do
before
do
Thread
.
current
[
:is_com
]
=
nil
end
it
'is true when on GitLab.com'
do
it
'is true when on GitLab.com'
do
allow
(
LightSettings
).
to
receive
(
:host
).
and_return
(
'
gitlab.com'
)
stub_config_setting
(
url:
'https://
gitlab.com'
)
expect
(
described_class
.
com?
).
to
eq
true
expect
(
described_class
.
com?
).
to
eq
true
end
end
it
'is true when on staging'
do
it
'is true when on staging'
do
allow
(
LightSettings
).
to
receive
(
:host
).
and_return
(
'
staging.gitlab.com'
)
stub_config_setting
(
url:
'https://
staging.gitlab.com'
)
expect
(
described_class
.
com?
).
to
eq
true
expect
(
described_class
.
com?
).
to
eq
true
end
end
it
'is true when on other gitlab subdomain'
do
it
'is true when on other gitlab subdomain'
do
allow
(
LightSettings
).
to
receive
(
:host
).
and_return
(
'
example.gitlab.com'
)
stub_config_setting
(
url:
'https://
example.gitlab.com'
)
expect
(
described_class
.
com?
).
to
eq
true
expect
(
described_class
.
com?
).
to
eq
true
end
end
it
'is false when not on GitLab.com'
do
it
'is false when not on GitLab.com'
do
allow
(
LightSettings
).
to
receive
(
:host
).
and_return
(
'
example.com'
)
stub_config_setting
(
url:
'http://
example.com'
)
expect
(
described_class
.
com?
).
to
eq
false
expect
(
described_class
.
com?
).
to
eq
false
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