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
7141831e
Commit
7141831e
authored
Feb 24, 2021
by
Pavel Shutsin
Committed by
Thong Kuah
Feb 24, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use default license path in seeds
In dev mode we can use license in default license path if it exists
parent
4c9f18d1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
ee/lib/tasks/gitlab/license.rake
ee/lib/tasks/gitlab/license.rake
+3
-8
ee/spec/tasks/gitlab/license_rake_spec.rb
ee/spec/tasks/gitlab/license_rake_spec.rb
+25
-2
No files found.
ee/lib/tasks/gitlab/license.rake
View file @
7141831e
...
@@ -16,15 +16,8 @@ namespace :gitlab do
...
@@ -16,15 +16,8 @@ namespace :gitlab do
task
:load
,
[
:mode
]
=>
:environment
do
|
_
,
args
|
task
:load
,
[
:mode
]
=>
:environment
do
|
_
,
args
|
args
.
with_defaults
(
mode:
'default'
)
args
.
with_defaults
(
mode:
'default'
)
verbose
=
args
[
:mode
]
==
'verbose'
flag
=
'GITLAB_LICENSE_FILE'
flag
=
'GITLAB_LICENSE_FILE'
if
ENV
[
flag
].
blank?
&&
verbose
puts
"Skipped. Use the `
#{
flag
}
` environment variable to seed the License file of the given path."
next
end
default_license_file
=
Settings
.
source
.
dirname
+
'Gitlab.gitlab-license'
default_license_file
=
Settings
.
source
.
dirname
+
'Gitlab.gitlab-license'
license_file
=
ENV
.
fetch
(
flag
,
default_license_file
)
license_file
=
ENV
.
fetch
(
flag
,
default_license_file
)
...
@@ -35,9 +28,11 @@ namespace :gitlab do
...
@@ -35,9 +28,11 @@ namespace :gitlab do
puts
"License Invalid:
\n\n
FilePath:
#{
license_file
}
"
.
color
(
:red
)
puts
"License Invalid:
\n\n
FilePath:
#{
license_file
}
"
.
color
(
:red
)
raise
"License Invalid"
raise
"License Invalid"
end
end
elsif
!
ENV
[
flag
].
blank
?
elsif
ENV
[
flag
].
present
?
puts
"License File Missing:
\n\n
FilePath:
#{
license_file
}
"
.
color
(
:red
)
puts
"License File Missing:
\n\n
FilePath:
#{
license_file
}
"
.
color
(
:red
)
raise
"License File Missing"
raise
"License File Missing"
elsif
args
[
:mode
]
==
'verbose'
puts
"Skipped. Use the `
#{
flag
}
` environment variable to seed the License file of the given path."
end
end
end
end
end
end
...
...
ee/spec/tasks/gitlab/license_rake_spec.rb
View file @
7141831e
...
@@ -3,6 +3,8 @@
...
@@ -3,6 +3,8 @@
require
'rake_helper'
require
'rake_helper'
RSpec
.
describe
'gitlab:license namespace rake tasks'
do
RSpec
.
describe
'gitlab:license namespace rake tasks'
do
let
(
:default_license_path
)
{
Settings
.
source
.
dirname
+
'Gitlab.gitlab-license'
}
before
do
before
do
Rake
.
application
.
rake_require
'tasks/gitlab/license'
Rake
.
application
.
rake_require
'tasks/gitlab/license'
end
end
...
@@ -56,11 +58,32 @@ RSpec.describe 'gitlab:license namespace rake tasks' do
...
@@ -56,11 +58,32 @@ RSpec.describe 'gitlab:license namespace rake tasks' do
end
end
end
end
context
'when GITLAB_LICENSE_FILE env variable is not set'
do
let
(
:license_file_contents
)
{
'valid contents'
}
context
'when default valid license file does exist'
do
before
do
allow
(
File
).
to
receive
(
:file?
).
with
(
default_license_path
).
and_return
(
true
)
end
it
'succeeds in adding the license'
do
expect_file_read
(
default_license_path
,
content:
license_file_contents
)
expect
(
License
).
to
receive
(
:create
).
with
(
data:
license_file_contents
).
and_return
(
true
)
expect
{
subject
}.
not_to
raise_error
end
end
end
context
'running in mode verbose'
do
context
'running in mode verbose'
do
let
(
:mode
)
{
'verbose'
}
let
(
:mode
)
{
'verbose'
}
it
'outputs a the help message'
do
context
'when default valid license file does not exist'
do
expect
{
subject
}.
to
output
(
/environment variable to seed the License file of the given path/
).
to_stdout
it
'outputs a the help message'
do
allow
(
File
).
to
receive
(
:file?
).
with
(
default_license_path
).
and_return
(
false
)
expect
{
subject
}.
to
output
(
/environment variable to seed the License file of the given path/
).
to_stdout
end
end
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