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
de0e4dec
Commit
de0e4dec
authored
Aug 11, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor package creation in maven packages API
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
68237290
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
40 additions
and
30 deletions
+40
-30
ee/app/services/packages/find_or_create_maven_package_service.rb
...services/packages/find_or_create_maven_package_service.rb
+38
-0
ee/lib/api/maven_packages.rb
ee/lib/api/maven_packages.rb
+2
-30
No files found.
ee/app/services/packages/find_or_create_maven_package_service.rb
0 → 100644
View file @
de0e4dec
# frozen_string_literal: true
module
Packages
class
FindOrCreateMavenPackageService
<
BaseService
MAVEN_METADATA_FILE
=
'maven-metadata.xml'
.
freeze
def
execute
package
=
::
Packages
::
MavenPackageFinder
.
new
(
project
,
params
[
:path
]).
execute
unless
package
if
params
[
:file_name
]
==
MAVEN_METADATA_FILE
# Maven uploads several files during `mvn deploy` in next order:
# - my-company/my-app/1.0-SNAPSHOT/my-app.jar
# - my-company/my-app/1.0-SNAPSHOT/my-app.pom
# - my-company/my-app/1.0-SNAPSHOT/maven-metadata.xml
# - my-company/my-app/maven-metadata.xml
#
# The last xml file does not have VERSION in URL because it contains
# information about all versions.
package_name
,
version
=
params
[
:path
],
nil
else
package_name
,
_
,
version
=
params
[
:path
].
rpartition
(
'/'
)
end
package_params
=
{
name:
package_name
,
path:
params
[
:path
],
version:
version
}
package
=
::
Packages
::
CreateMavenPackageService
.
new
(
project
,
current_user
,
package_params
).
execute
end
package
end
end
end
ee/lib/api/maven_packages.rb
View file @
de0e4dec
...
...
@@ -5,8 +5,6 @@ module API
file_name:
API
::
NO_SLASH_URL_PART_REGEX
}.
freeze
MAVEN_METADATA_FILE
=
'maven-metadata.xml'
.
freeze
content_type
:md5
,
'text/plain'
content_type
:sha1
,
'text/plain'
content_type
:binary
,
'application/octet-stream'
...
...
@@ -122,7 +120,6 @@ module API
end
put
':id/packages/maven/*path/:file_name'
,
requirements:
MAVEN_ENDPOINT_REQUIREMENTS
do
authorize_create_package!
require_gitlab_workhorse!
file_name
,
format
=
extract_format
(
params
[
:file_name
])
...
...
@@ -130,33 +127,8 @@ module API
uploaded_file
=
UploadedFile
.
from_params
(
params
,
:file
,
::
Packages
::
PackageFileUploader
.
workhorse_local_upload_path
)
bad_request!
(
'Missing package file!'
)
unless
uploaded_file
package
=
::
Packages
::
MavenPackageFinder
.
new
(
user_project
,
params
[
:path
]).
execute
unless
package
if
file_name
==
MAVEN_METADATA_FILE
# Maven uploads several files during `mvn deploy` in next order:
# - my-company/my-app/1.0-SNAPSHOT/my-app.jar
# - my-company/my-app/1.0-SNAPSHOT/my-app.pom
# - my-company/my-app/1.0-SNAPSHOT/maven-metadata.xml
# - my-company/my-app/maven-metadata.xml
#
# The last xml file does not have VERSION in URL because it contains
# information about all versions.
package_name
,
version
=
params
[
:path
],
nil
else
package_name
,
_
,
version
=
params
[
:path
].
rpartition
(
'/'
)
end
package_params
=
{
name:
package_name
,
path:
params
[
:path
],
version:
version
}
package
=
::
Packages
::
CreateMavenPackageService
.
new
(
user_project
,
current_user
,
package_params
).
execute
end
package
=
::
Packages
::
FindOrCreateMavenPackageService
.
new
(
user_project
,
current_user
,
params
).
execute
case
format
when
'sha1'
...
...
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