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
671d53f6
Commit
671d53f6
authored
Jan 14, 2021
by
Mathieu Parent
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Debian package upload to API
parent
4fbfaff7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
37 additions
and
2 deletions
+37
-2
lib/api/debian_project_packages.rb
lib/api/debian_project_packages.rb
+15
-0
spec/requests/api/debian_project_packages_spec.rb
spec/requests/api/debian_project_packages_spec.rb
+12
-1
spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb
..._examples/requests/api/debian_packages_shared_examples.rb
+10
-1
No files found.
lib/api/debian_project_packages.rb
View file @
671d53f6
...
...
@@ -37,6 +37,21 @@ module API
track_package_event
(
'push_package'
,
:debian
)
file_params
=
{
file:
params
[
'file'
],
file_name:
params
[
'file_name'
],
file_sha1:
params
[
'file.sha1'
],
file_md5:
params
[
'file.md5'
]
}
package
=
::
Packages
::
Debian
::
FindOrCreateIncomingService
.
new
(
authorized_user_project
,
current_user
).
execute
package_file
=
::
Packages
::
Debian
::
CreatePackageFileService
.
new
(
package
,
file_params
).
execute
if
params
[
'file_name'
].
end_with?
'.changes'
::
Packages
::
Debian
::
ProcessChangesWorker
.
perform_async
(
package_file
.
id
,
current_user
.
id
)
# rubocop:disable CodeReuse/Worker
end
created!
rescue
ObjectStorage
::
RemoteStoreError
=>
e
Gitlab
::
ErrorTracking
.
track_exception
(
e
,
extra:
{
file_name:
params
[
:file_name
],
project_id:
authorized_user_project
.
id
})
...
...
spec/requests/api/debian_project_packages_spec.rb
View file @
671d53f6
...
...
@@ -40,10 +40,21 @@ RSpec.describe API::DebianProjectPackages do
let
(
:method
)
{
:put
}
let
(
:url
)
{
"/projects/
#{
container
.
id
}
/packages/debian/
#{
file_name
}
"
}
it_behaves_like
'Debian repository write endpoint'
,
'upload request'
,
:created
context
'with a deb'
do
let
(
:file_name
)
{
'libsample0_1.2.3~alpha2_amd64.deb'
}
it_behaves_like
'Debian repository write endpoint'
,
'upload request'
,
:created
end
context
'with a changes file'
do
let
(
:file_name
)
{
'sample_1.2.3~alpha2_amd64.changes'
}
it_behaves_like
'Debian repository write endpoint'
,
'upload request'
,
:created
end
end
describe
'PUT projects/:id/packages/debian/:file_name/authorize'
do
let
(
:file_name
)
{
'libsample0_1.2.3~alpha2_amd64.deb'
}
let
(
:method
)
{
:put
}
let
(
:url
)
{
"/projects/
#{
container
.
id
}
/packages/debian/
#{
file_name
}
/authorize"
}
...
...
spec/support/shared_examples/requests/api/debian_packages_shared_examples.rb
View file @
671d53f6
...
...
@@ -107,10 +107,19 @@ RSpec.shared_examples 'Debian repository upload request' do |status, body = nil|
if
status
==
:created
it
'creates package files'
,
:aggregate_failures
do
pending
"Debian package creation not implemented"
expect
(
::
Packages
::
Debian
::
FindOrCreateIncomingService
).
to
receive
(
:new
).
with
(
container
,
user
).
and_call_original
expect
(
::
Packages
::
Debian
::
CreatePackageFileService
).
to
receive
(
:new
).
with
(
be_a
(
Packages
::
Package
),
be_an
(
Hash
)).
and_call_original
if
file_name
.
end_with?
'.changes'
expect
(
::
Packages
::
Debian
::
ProcessChangesWorker
).
to
receive
(
:perform_async
)
else
expect
(
::
Packages
::
Debian
::
ProcessChangesWorker
).
not_to
receive
(
:perform_async
)
end
expect
{
subject
}
.
to
change
{
container
.
packages
.
debian
.
count
}.
by
(
1
)
.
and
change
{
container
.
packages
.
debian
.
where
(
name:
'incoming'
).
count
}.
by
(
1
)
.
and
change
{
container
.
package_files
.
count
}.
by
(
1
)
expect
(
response
).
to
have_gitlab_http_status
(
status
)
expect
(
response
.
media_type
).
to
eq
(
'text/plain'
)
...
...
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