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
7ceecf83
Commit
7ceecf83
authored
Nov 24, 2020
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Debian Group and Project Distribution Components
See #5835
parent
fdd90a25
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
263 additions
and
0 deletions
+263
-0
app/models/concerns/packages/debian/component.rb
app/models/concerns/packages/debian/component.rb
+25
-0
app/models/concerns/packages/debian/distribution.rb
app/models/concerns/packages/debian/distribution.rb
+4
-0
app/models/packages/debian/group_component.rb
app/models/packages/debian/group_component.rb
+9
-0
app/models/packages/debian/project_component.rb
app/models/packages/debian/project_component.rb
+9
-0
changelogs/unreleased/debian_distribution_components.yml
changelogs/unreleased/debian_distribution_components.yml
+5
-0
db/migrate/20201204111200_create_packages_debian_project_components.rb
...201204111200_create_packages_debian_project_components.rb
+35
-0
db/migrate/20201204111300_create_packages_debian_group_components.rb
...20201204111300_create_packages_debian_group_components.rb
+35
-0
db/schema_migrations/20201204111200
db/schema_migrations/20201204111200
+1
-0
db/schema_migrations/20201204111300
db/schema_migrations/20201204111300
+1
-0
db/structure.sql
db/structure.sql
+56
-0
spec/factories/packages/debian/group_component.rb
spec/factories/packages/debian/group_component.rb
+9
-0
spec/factories/packages/debian/project_component.rb
spec/factories/packages/debian/project_component.rb
+9
-0
spec/models/packages/debian/group_component_spec.rb
spec/models/packages/debian/group_component_spec.rb
+7
-0
spec/models/packages/debian/project_component_spec.rb
spec/models/packages/debian/project_component_spec.rb
+7
-0
spec/support/shared_examples/models/packages/debian/component_shared_examples.rb
...mples/models/packages/debian/component_shared_examples.rb
+50
-0
spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb
...es/models/packages/debian/distribution_shared_examples.rb
+1
-0
No files found.
app/models/concerns/packages/debian/component.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
module
Packages
module
Debian
module
Component
extend
ActiveSupport
::
Concern
included
do
belongs_to
:distribution
,
class_name:
"Packages::Debian::
#{
container_type
.
capitalize
}
Distribution"
,
inverse_of: :components
validates
:distribution
,
presence:
true
validates
:name
,
presence:
true
,
length:
{
maximum:
255
},
uniqueness:
{
scope:
%i[distribution_id]
},
format:
{
with:
Gitlab
::
Regex
.
debian_component_regex
}
scope
:with_distribution
,
->
(
distribution
)
{
where
(
distribution:
distribution
)
}
scope
:with_name
,
->
(
name
)
{
where
(
name:
name
)
}
end
end
end
end
app/models/concerns/packages/debian/distribution.rb
View file @
7ceecf83
...
...
@@ -18,6 +18,10 @@ module Packages
belongs_to
container_type
belongs_to
:creator
,
class_name:
'User'
has_many
:components
,
class_name:
"Packages::Debian::
#{
container_type
.
capitalize
}
Component"
,
foreign_key: :distribution_id
,
inverse_of: :distribution
has_many
:architectures
,
class_name:
"Packages::Debian::
#{
container_type
.
capitalize
}
Architecture"
,
foreign_key: :distribution_id
,
...
...
app/models/packages/debian/group_component.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
class
Packages::Debian::GroupComponent
<
ApplicationRecord
def
self
.
container_type
:group
end
include
Packages
::
Debian
::
Component
end
app/models/packages/debian/project_component.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
class
Packages::Debian::ProjectComponent
<
ApplicationRecord
def
self
.
container_type
:project
end
include
Packages
::
Debian
::
Component
end
changelogs/unreleased/debian_distribution_components.yml
0 → 100644
View file @
7ceecf83
---
title
:
Debian Group and Project Distribution Components
merge_request
:
51732
author
:
Mathieu Parent
type
:
added
db/migrate/20201204111200_create_packages_debian_project_components.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
class
CreatePackagesDebianProjectComponents
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
UNIQUE_NAME
=
'uniq_pkgs_deb_proj_components_on_distribution_id_and_name'
disable_ddl_transaction!
def
up
unless
table_exists?
(
:packages_debian_project_components
)
create_table
:packages_debian_project_components
do
|
t
|
t
.
timestamps_with_timezone
t
.
references
:distribution
,
foreign_key:
{
to_table: :packages_debian_project_distributions
,
on_delete: :cascade
},
null:
false
,
index:
false
t
.
text
:name
,
null:
false
t
.
index
%w(distribution_id name)
,
name:
UNIQUE_NAME
,
unique:
true
,
using: :btree
end
end
add_text_limit
:packages_debian_project_components
,
:name
,
255
end
def
down
drop_table
:packages_debian_project_components
end
end
db/migrate/20201204111300_create_packages_debian_group_components.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
class
CreatePackagesDebianGroupComponents
<
ActiveRecord
::
Migration
[
5.2
]
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
UNIQUE_NAME
=
'uniq_pkgs_deb_grp_components_on_distribution_id_and_name'
disable_ddl_transaction!
def
up
unless
table_exists?
(
:packages_debian_group_components
)
create_table
:packages_debian_group_components
do
|
t
|
t
.
timestamps_with_timezone
t
.
references
:distribution
,
foreign_key:
{
to_table: :packages_debian_group_distributions
,
on_delete: :cascade
},
null:
false
,
index:
false
t
.
text
:name
,
null:
false
t
.
index
%w(distribution_id name)
,
name:
UNIQUE_NAME
,
unique:
true
,
using: :btree
end
end
add_text_limit
:packages_debian_group_components
,
:name
,
255
end
def
down
drop_table
:packages_debian_group_components
end
end
db/schema_migrations/20201204111200
0 → 100644
View file @
7ceecf83
2aad94b0577882df4fec3df3806993858dad9f4eb20db71c94f8590c6640d62e
\ No newline at end of file
db/schema_migrations/20201204111300
0 → 100644
View file @
7ceecf83
e1265a293640d0d067672cb0426987c4a308025cf5a15b17bac8e30267dc8eaf
\ No newline at end of file
db/structure.sql
View file @
7ceecf83
...
...
@@ -14859,6 +14859,24 @@ CREATE SEQUENCE packages_debian_group_architectures_id_seq
ALTER
SEQUENCE
packages_debian_group_architectures_id_seq
OWNED
BY
packages_debian_group_architectures
.
id
;
CREATE
TABLE
packages_debian_group_components
(
id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
updated_at
timestamp
with
time
zone
NOT
NULL
,
distribution_id
bigint
NOT
NULL
,
name
text
NOT
NULL
,
CONSTRAINT
check_a9bc7d85be
CHECK
((
char_length
(
name
)
<=
255
))
);
CREATE
SEQUENCE
packages_debian_group_components_id_seq
START
WITH
1
INCREMENT
BY
1
NO
MINVALUE
NO
MAXVALUE
CACHE
1
;
ALTER
SEQUENCE
packages_debian_group_components_id_seq
OWNED
BY
packages_debian_group_components
.
id
;
CREATE
TABLE
packages_debian_group_distributions
(
id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
...
...
@@ -14918,6 +14936,24 @@ CREATE SEQUENCE packages_debian_project_architectures_id_seq
ALTER
SEQUENCE
packages_debian_project_architectures_id_seq
OWNED
BY
packages_debian_project_architectures
.
id
;
CREATE
TABLE
packages_debian_project_components
(
id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
updated_at
timestamp
with
time
zone
NOT
NULL
,
distribution_id
bigint
NOT
NULL
,
name
text
NOT
NULL
,
CONSTRAINT
check_517559f298
CHECK
((
char_length
(
name
)
<=
255
))
);
CREATE
SEQUENCE
packages_debian_project_components_id_seq
START
WITH
1
INCREMENT
BY
1
NO
MINVALUE
NO
MAXVALUE
CACHE
1
;
ALTER
SEQUENCE
packages_debian_project_components_id_seq
OWNED
BY
packages_debian_project_components
.
id
;
CREATE
TABLE
packages_debian_project_distributions
(
id
bigint
NOT
NULL
,
created_at
timestamp
with
time
zone
NOT
NULL
,
...
...
@@ -18914,10 +18950,14 @@ ALTER TABLE ONLY packages_conan_metadata ALTER COLUMN id SET DEFAULT nextval('pa
ALTER
TABLE
ONLY
packages_debian_group_architectures
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_debian_group_architectures_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
packages_debian_group_components
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_debian_group_components_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
packages_debian_group_distributions
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_debian_group_distributions_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
packages_debian_project_architectures
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_debian_project_architectures_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
packages_debian_project_components
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_debian_project_components_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
packages_debian_project_distributions
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_debian_project_distributions_id_seq'
::
regclass
);
ALTER
TABLE
ONLY
packages_dependencies
ALTER
COLUMN
id
SET
DEFAULT
nextval
(
'packages_dependencies_id_seq'
::
regclass
);
...
...
@@ -20283,12 +20323,18 @@ ALTER TABLE ONLY packages_debian_file_metadata
ALTER
TABLE
ONLY
packages_debian_group_architectures
ADD
CONSTRAINT
packages_debian_group_architectures_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
packages_debian_group_components
ADD
CONSTRAINT
packages_debian_group_components_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
packages_debian_group_distributions
ADD
CONSTRAINT
packages_debian_group_distributions_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
packages_debian_project_architectures
ADD
CONSTRAINT
packages_debian_project_architectures_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
packages_debian_project_components
ADD
CONSTRAINT
packages_debian_project_components_pkey
PRIMARY
KEY
(
id
);
ALTER
TABLE
ONLY
packages_debian_project_distributions
ADD
CONSTRAINT
packages_debian_project_distributions_pkey
PRIMARY
KEY
(
id
);
...
...
@@ -23460,8 +23506,12 @@ CREATE INDEX tmp_index_on_vulnerabilities_non_dismissed ON vulnerabilities USING
CREATE
UNIQUE
INDEX
uniq_pkgs_deb_grp_architectures_on_distribution_id_and_name
ON
packages_debian_group_architectures
USING
btree
(
distribution_id
,
name
);
CREATE
UNIQUE
INDEX
uniq_pkgs_deb_grp_components_on_distribution_id_and_name
ON
packages_debian_group_components
USING
btree
(
distribution_id
,
name
);
CREATE
UNIQUE
INDEX
uniq_pkgs_deb_proj_architectures_on_distribution_id_and_name
ON
packages_debian_project_architectures
USING
btree
(
distribution_id
,
name
);
CREATE
UNIQUE
INDEX
uniq_pkgs_deb_proj_components_on_distribution_id_and_name
ON
packages_debian_project_components
USING
btree
(
distribution_id
,
name
);
CREATE
UNIQUE
INDEX
uniq_pkgs_debian_group_distributions_group_id_and_codename
ON
packages_debian_group_distributions
USING
btree
(
group_id
,
codename
);
CREATE
UNIQUE
INDEX
uniq_pkgs_debian_group_distributions_group_id_and_suite
ON
packages_debian_group_distributions
USING
btree
(
group_id
,
suite
);
...
...
@@ -25321,6 +25371,9 @@ ALTER TABLE ONLY users_ops_dashboard_projects
ALTER
TABLE
ONLY
project_incident_management_settings
ADD
CONSTRAINT
fk_rails_9c2ea1b7dd
FOREIGN
KEY
(
project_id
)
REFERENCES
projects
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
packages_debian_project_components
ADD
CONSTRAINT
fk_rails_9d072b5073
FOREIGN
KEY
(
distribution_id
)
REFERENCES
packages_debian_project_distributions
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
gpg_keys
ADD
CONSTRAINT
fk_rails_9d1f5d8719
FOREIGN
KEY
(
user_id
)
REFERENCES
users
(
id
)
ON
DELETE
CASCADE
;
...
...
@@ -25783,6 +25836,9 @@ ALTER TABLE ONLY board_group_recent_visits
ALTER
TABLE
ONLY
resource_state_events
ADD
CONSTRAINT
fk_rails_f5827a7ccd
FOREIGN
KEY
(
user_id
)
REFERENCES
users
(
id
)
ON
DELETE
SET
NULL
;
ALTER
TABLE
ONLY
packages_debian_group_components
ADD
CONSTRAINT
fk_rails_f5f1ef54c6
FOREIGN
KEY
(
distribution_id
)
REFERENCES
packages_debian_group_distributions
(
id
)
ON
DELETE
CASCADE
;
ALTER
TABLE
ONLY
incident_management_oncall_shifts
ADD
CONSTRAINT
fk_rails_f6eef06841
FOREIGN
KEY
(
participant_id
)
REFERENCES
incident_management_oncall_participants
(
id
)
ON
DELETE
CASCADE
;
...
...
spec/factories/packages/debian/group_component.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:debian_group_component
,
class:
'Packages::Debian::GroupComponent'
do
distribution
{
association
(
:debian_group_distribution
)
}
sequence
(
:name
)
{
|
n
|
"group-component-
#{
n
}
"
}
end
end
spec/factories/packages/debian/project_component.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
FactoryBot
.
define
do
factory
:debian_project_component
,
class:
'Packages::Debian::ProjectComponent'
do
distribution
{
association
(
:debian_project_distribution
)
}
sequence
(
:name
)
{
|
n
|
"project-component-
#{
n
}
"
}
end
end
spec/models/packages/debian/group_component_spec.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Packages
::
Debian
::
GroupComponent
do
it_behaves_like
'Debian Distribution Component'
,
:debian_group_component
,
:group
,
false
end
spec/models/packages/debian/project_component_spec.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Packages
::
Debian
::
ProjectComponent
do
it_behaves_like
'Debian Distribution Component'
,
:debian_project_component
,
:project
,
true
end
spec/support/shared_examples/models/packages/debian/component_shared_examples.rb
0 → 100644
View file @
7ceecf83
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
shared_examples
'Debian Distribution Component'
do
|
factory
,
container
,
can_freeze
|
let_it_be_with_refind
(
:component
)
{
create
(
factory
)
}
# rubocop:disable Rails/SaveBang
let_it_be
(
:component_same_distribution
,
freeze:
can_freeze
)
{
create
(
factory
,
distribution:
component
.
distribution
)
}
let_it_be
(
:component_same_name
,
freeze:
can_freeze
)
{
create
(
factory
,
name:
component
.
name
)
}
subject
{
component
}
describe
'relationships'
do
it
{
is_expected
.
to
belong_to
(
:distribution
).
class_name
(
"Packages::Debian::
#{
container
.
capitalize
}
Distribution"
).
inverse_of
(
:components
)
}
end
describe
'validations'
do
describe
"#distribution"
do
it
{
is_expected
.
to
validate_presence_of
(
:distribution
)
}
end
describe
'#name'
do
it
{
is_expected
.
to
validate_presence_of
(
:name
)
}
it
{
is_expected
.
to
allow_value
(
'main'
).
for
(
:name
)
}
it
{
is_expected
.
to
allow_value
(
'non-free'
).
for
(
:name
)
}
it
{
is_expected
.
to
allow_value
(
'a'
*
255
).
for
(
:name
)
}
it
{
is_expected
.
not_to
allow_value
(
'a'
*
256
).
for
(
:name
)
}
it
{
is_expected
.
not_to
allow_value
(
'non/free'
).
for
(
:name
)
}
it
{
is_expected
.
not_to
allow_value
(
'hé'
).
for
(
:name
)
}
end
end
describe
'scopes'
do
describe
'.with_distribution'
do
subject
{
described_class
.
with_distribution
(
component
.
distribution
)
}
it
'does not return other distributions'
do
expect
(
subject
.
to_a
).
to
eq
([
component
,
component_same_distribution
])
end
end
describe
'.with_name'
do
subject
{
described_class
.
with_name
(
component
.
name
)
}
it
'does not return other distributions'
do
expect
(
subject
.
to_a
).
to
eq
([
component
,
component_same_name
])
end
end
end
end
spec/support/shared_examples/models/packages/debian/distribution_shared_examples.rb
View file @
7ceecf83
...
...
@@ -17,6 +17,7 @@ RSpec.shared_examples 'Debian Distribution' do |factory, container, can_freeze|
it
{
is_expected
.
to
belong_to
(
container
)
}
it
{
is_expected
.
to
belong_to
(
:creator
).
class_name
(
'User'
)
}
it
{
is_expected
.
to
have_many
(
:components
).
class_name
(
"Packages::Debian::
#{
container
.
capitalize
}
Component"
).
inverse_of
(
:distribution
)
}
it
{
is_expected
.
to
have_many
(
:architectures
).
class_name
(
"Packages::Debian::
#{
container
.
capitalize
}
Architecture"
).
inverse_of
(
:distribution
)
}
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