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
e6b45798
Commit
e6b45798
authored
Mar 15, 2021
by
Steve Abrams
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Include source in composer json payload
Include git source as part of the Composer version spec json
parent
ea498493
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
49 additions
and
6 deletions
+49
-6
app/models/packages/package.rb
app/models/packages/package.rb
+1
-0
changelogs/unreleased/247531-composer-source-jsonn.yml
changelogs/unreleased/247531-composer-source-jsonn.yml
+5
-0
doc/user/packages/composer_repository/index.md
doc/user/packages/composer_repository/index.md
+13
-0
lib/gitlab/composer/version_index.rb
lib/gitlab/composer/version_index.rb
+18
-4
spec/lib/gitlab/composer/version_index_spec.rb
spec/lib/gitlab/composer/version_index_spec.rb
+5
-0
spec/presenters/packages/composer/packages_presenter_spec.rb
spec/presenters/packages/composer/packages_presenter_spec.rb
+7
-2
No files found.
app/models/packages/package.rb
View file @
e6b45798
...
@@ -29,6 +29,7 @@ class Packages::Package < ApplicationRecord
...
@@ -29,6 +29,7 @@ class Packages::Package < ApplicationRecord
delegate
:recipe
,
:recipe_path
,
to: :conan_metadatum
,
prefix: :conan
delegate
:recipe
,
:recipe_path
,
to: :conan_metadatum
,
prefix: :conan
delegate
:codename
,
:suite
,
to: :debian_distribution
,
prefix: :debian_distribution
delegate
:codename
,
:suite
,
to: :debian_distribution
,
prefix: :debian_distribution
delegate
:target_sha
,
to: :composer_metadatum
,
prefix: :composer
validates
:project
,
presence:
true
validates
:project
,
presence:
true
validates
:name
,
presence:
true
validates
:name
,
presence:
true
...
...
changelogs/unreleased/247531-composer-source-jsonn.yml
0 → 100644
View file @
e6b45798
---
title
:
Support for --prefer-source option for Composer registry
merge_request
:
56693
author
:
type
:
changed
doc/user/packages/composer_repository/index.md
View file @
e6b45798
...
@@ -274,8 +274,21 @@ To install a package:
...
@@ -274,8 +274,21 @@ To install a package:
composer update
composer update
```
```
Or to install the single package:
```
shell
composer req <package-name>:<package-version>
```
If successful, you should see output indicating that the package installed successfully.
If successful, you should see output indicating that the package installed successfully.
You can also install from source (by pulling the Git repository directly) using the
`--prefer-source`
option:
```
shell
composer update
--prefer-source
```
WARNING:
WARNING:
Never commit the
`auth.json`
file to your repository. To install packages from a CI/CD job,
Never commit the
`auth.json`
file to your repository. To install packages from a CI/CD job,
consider using the
[
`composer config`
](
https://getcomposer.org/doc/articles/handling-private-packages.md#satis
)
tool with your personal access token
consider using the
[
`composer config`
](
https://getcomposer.org/doc/articles/handling-private-packages.md#satis
)
tool with your personal access token
...
...
lib/gitlab/composer/version_index.rb
View file @
e6b45798
...
@@ -28,20 +28,34 @@ module Gitlab
...
@@ -28,20 +28,34 @@ module Gitlab
def
package_metadata
(
package
)
def
package_metadata
(
package
)
json
=
package
.
composer_metadatum
.
composer_json
json
=
package
.
composer_metadatum
.
composer_json
json
.
merge
(
'dist'
=>
package_dist
(
package
),
'uid'
=>
package
.
id
,
'version'
=>
package
.
version
)
json
.
merge
(
'dist'
=>
package_dist
(
package
),
'source'
=>
package_source
(
package
),
'uid'
=>
package
.
id
,
'version'
=>
package
.
version
)
end
end
def
package_dist
(
package
)
def
package_dist
(
package
)
sha
=
package
.
composer_metadatum
.
target_sha
archive_api_path
=
api_v4_projects_packages_composer_archives_package_name_path
({
id:
package
.
project_id
,
package_name:
package
.
name
,
format:
'.zip'
},
true
)
archive_api_path
=
api_v4_projects_packages_composer_archives_package_name_path
({
id:
package
.
project_id
,
package_name:
package
.
name
,
format:
'.zip'
},
true
)
{
{
'type'
=>
'zip'
,
'type'
=>
'zip'
,
'url'
=>
expose_url
(
archive_api_path
)
+
"?sha=
#{
sha
}
"
,
'url'
=>
expose_url
(
archive_api_path
)
+
"?sha=
#{
package
.
composer_target_
sha
}
"
,
'reference'
=>
sha
,
'reference'
=>
package
.
composer_target_
sha
,
'shasum'
=>
''
'shasum'
=>
''
}
}
end
end
def
package_source
(
package
)
git_url
=
package
.
project
.
http_url_to_repo
{
'type'
=>
'git'
,
'url'
=>
git_url
,
'reference'
=>
package
.
composer_target_sha
}
end
end
end
end
end
end
end
spec/lib/gitlab/composer/version_index_spec.rb
View file @
e6b45798
...
@@ -27,6 +27,11 @@ RSpec.describe Gitlab::Composer::VersionIndex do
...
@@ -27,6 +27,11 @@ RSpec.describe Gitlab::Composer::VersionIndex do
'type'
=>
'zip'
,
'type'
=>
'zip'
,
'url'
=>
"http://localhost/api/v4/projects/
#{
project
.
id
}
/packages/composer/archives/
#{
package
.
name
}
.zip?sha=
#{
branch
.
target
}
"
'url'
=>
"http://localhost/api/v4/projects/
#{
project
.
id
}
/packages/composer/archives/
#{
package
.
name
}
.zip?sha=
#{
branch
.
target
}
"
},
},
'source'
=>
{
'reference'
=>
branch
.
target
,
'type'
=>
'git'
,
'url'
=>
project
.
http_url_to_repo
},
'name'
=>
package
.
name
,
'name'
=>
package
.
name
,
'uid'
=>
package
.
id
,
'uid'
=>
package
.
id
,
'version'
=>
package
.
version
'version'
=>
package
.
version
...
...
spec/presenters/packages/composer/packages_presenter_spec.rb
View file @
e6b45798
...
@@ -9,8 +9,8 @@ RSpec.describe ::Packages::Composer::PackagesPresenter do
...
@@ -9,8 +9,8 @@ RSpec.describe ::Packages::Composer::PackagesPresenter do
let_it_be
(
:json
)
{
{
'name'
=>
package_name
}
}
let_it_be
(
:json
)
{
{
'name'
=>
package_name
}
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:group
)
{
create
(
:group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'composer.json'
=>
json
.
to_json
},
group:
group
)
}
let_it_be
(
:project
)
{
create
(
:project
,
:custom_repo
,
files:
{
'composer.json'
=>
json
.
to_json
},
group:
group
)
}
let
_it_be
(
:package1
)
{
create
(
:composer_package
,
:with_metadatum
,
project:
project
,
name:
package_name
,
version:
'1.0.0'
,
json:
json
)
}
let
!
(
:package1
)
{
create
(
:composer_package
,
:with_metadatum
,
project:
project
,
name:
package_name
,
version:
'1.0.0'
,
json:
json
)
}
let
_it_be
(
:package2
)
{
create
(
:composer_package
,
:with_metadatum
,
project:
project
,
name:
package_name
,
version:
'2.0.0'
,
json:
json
)
}
let
!
(
:package2
)
{
create
(
:composer_package
,
:with_metadatum
,
project:
project
,
name:
package_name
,
version:
'2.0.0'
,
json:
json
)
}
let
(
:branch
)
{
project
.
repository
.
find_branch
(
'master'
)
}
let
(
:branch
)
{
project
.
repository
.
find_branch
(
'master'
)
}
...
@@ -28,6 +28,11 @@ RSpec.describe ::Packages::Composer::PackagesPresenter do
...
@@ -28,6 +28,11 @@ RSpec.describe ::Packages::Composer::PackagesPresenter do
'type'
=>
'zip'
,
'type'
=>
'zip'
,
'url'
=>
"http://localhost/api/v4/projects/
#{
project
.
id
}
/packages/composer/archives/
#{
package
.
name
}
.zip?sha=
#{
branch
.
target
}
"
'url'
=>
"http://localhost/api/v4/projects/
#{
project
.
id
}
/packages/composer/archives/
#{
package
.
name
}
.zip?sha=
#{
branch
.
target
}
"
},
},
'source'
=>
{
'reference'
=>
branch
.
target
,
'type'
=>
'git'
,
'url'
=>
"http://localhost/
#{
group
.
path
}
/
#{
project
.
path
}
.git"
},
'name'
=>
package
.
name
,
'name'
=>
package
.
name
,
'uid'
=>
package
.
id
,
'uid'
=>
package
.
id
,
'version'
=>
package
.
version
'version'
=>
package
.
version
...
...
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