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
cfdf221a
Commit
cfdf221a
authored
Feb 03, 2022
by
Imre Farkas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make granting of open-source license to public projects configurable
Changelog: added
parent
33c3e20e
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
60 additions
and
1 deletion
+60
-1
app/models/project_setting.rb
app/models/project_setting.rb
+4
-0
config/feature_flags/ops/legacy_open_source_license_available.yml
...eature_flags/ops/legacy_open_source_license_available.yml
+8
-0
db/migrate/20220203133652_add_legacy_open_source_license_available_to_project_settings.rb
...gacy_open_source_license_available_to_project_settings.rb
+9
-0
db/schema_migrations/20220203133652
db/schema_migrations/20220203133652
+1
-0
db/structure.sql
db/structure.sql
+1
-0
ee/app/models/ee/project.rb
ee/app/models/ee/project.rb
+7
-1
ee/spec/models/project_spec.rb
ee/spec/models/project_spec.rb
+29
-0
spec/requests/api/project_attributes.yml
spec/requests/api/project_attributes.yml
+1
-0
No files found.
app/models/project_setting.rb
View file @
cfdf221a
...
...
@@ -15,6 +15,10 @@ class ProjectSetting < ApplicationRecord
validates
:merge_commit_template
,
length:
{
maximum:
500
}
validates
:squash_commit_template
,
length:
{
maximum:
500
}
default_value_for
(
:legacy_open_source_license_available
)
do
Feature
.
enabled?
(
:legacy_open_source_license_available
,
default_enabled: :yaml
,
type: :ops
)
end
def
squash_enabled_by_default?
%w[always default_on]
.
include?
(
squash_option
)
end
...
...
config/feature_flags/ops/legacy_open_source_license_available.yml
0 → 100644
View file @
cfdf221a
---
name
:
legacy_open_source_license_available
introduced_by_url
:
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/79855
rollout_issue_url
:
milestone
:
'
14.8'
type
:
ops
group
:
'
group::authentication
and
authorization'
default_enabled
:
true
db/migrate/20220203133652_add_legacy_open_source_license_available_to_project_settings.rb
0 → 100644
View file @
cfdf221a
# frozen_string_literal: true
class
AddLegacyOpenSourceLicenseAvailableToProjectSettings
<
Gitlab
::
Database
::
Migration
[
1.0
]
enable_lock_retries!
def
change
add_column
:project_settings
,
:legacy_open_source_license_available
,
:boolean
,
default:
true
,
null:
false
end
end
db/schema_migrations/20220203133652
0 → 100644
View file @
cfdf221a
5642cf604a1aaf8bef6098a9918b582e0e336d79ca3b2a005cf90bb8eab0ca13
\ No newline at end of file
db/structure.sql
View file @
cfdf221a
...
...
@@ -18701,6 +18701,7 @@ CREATE TABLE project_settings (
has_shimo boolean DEFAULT false NOT NULL,
squash_commit_template text,
show_diff_preview_in_email boolean DEFAULT true NOT NULL,
legacy_open_source_license_available boolean DEFAULT true NOT NULL,
CONSTRAINT check_3a03e7557a CHECK ((char_length(previous_default_branch) <= 4096)),
CONSTRAINT check_b09644994b CHECK ((char_length(squash_commit_template) <= 500)),
CONSTRAINT check_bde223416c CHECK ((show_default_award_emojis IS NOT NULL)),
ee/app/models/ee/project.rb
View file @
cfdf221a
...
...
@@ -927,12 +927,18 @@ module EE
if
::
Gitlab
::
CurrentSettings
.
should_check_namespace_plan?
&&
namespace
globally_available
&&
(
public
?
&&
namespace
.
public
?
||
namespace
.
feature_available_in_plan?
(
feature
))
(
open_source_license_granted
?
||
namespace
.
feature_available_in_plan?
(
feature
))
else
globally_available
end
end
def
open_source_license_granted?
public
?
&&
namespace
.
public?
&&
project_setting
.
legacy_open_source_license_available?
end
def
user_defined_rules
strong_memoize
(:
user_defined_rules
)
do
# Loading the relation in order to memoize it loaded
...
...
ee/spec/models/project_spec.rb
View file @
cfdf221a
...
...
@@ -1256,6 +1256,35 @@ RSpec.describe Project do
subject
end
end
context
'legacy open-source license'
do
let
(
:feature
)
{
:sast
}
before
do
stub_application_setting
(
check_namespace_plan:
true
)
stub_licensed_features
(
feature
=>
true
)
end
context
'public projects'
do
let
(
:project
)
{
build
(
:project
,
:public
,
namespace:
namespace
)
}
context
'when legacy_open_source_license_available feature flag is enabled'
do
it
'allows ultimate features'
do
is_expected
.
to
eq
(
true
)
end
end
context
'when legacy_open_source_license_available feature flag is disabled'
do
before
do
stub_feature_flags
(
legacy_open_source_license_available:
false
)
end
it
'prevent ultimate features'
do
is_expected
.
to
eq
(
false
)
end
end
end
end
end
describe
'#fetch_mirror'
do
...
...
spec/requests/api/project_attributes.yml
View file @
cfdf221a
...
...
@@ -139,6 +139,7 @@ project_setting:
-
has_confluence
-
has_shimo
-
has_vulnerabilities
-
legacy_open_source_license_available
-
prevent_merge_without_jira_issue
-
warn_about_potentially_unwanted_characters
-
previous_default_branch
...
...
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