diff options
author | Douwe Maan <douwe@selenight.nl> | 2017-05-16 15:28:11 -0500 |
---|---|---|
committer | Douwe Maan <douwe@selenight.nl> | 2017-05-23 15:35:33 -0500 |
commit | fbec6dbd1a120cd111608c637cd63c8313aeb976 (patch) | |
tree | 55d6558aae77db706f606ae50308281cc425ae46 /lib | |
parent | 83747783e25b2d8b60efa2cb1aa9d6bd823fcdfe (diff) | |
download | gitlab-ce-fbec6dbd1a120cd111608c637cd63c8313aeb976.tar.gz |
Autolink package names in composer.json
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/dependency_linker.rb | 1 | ||||
-rw-r--r-- | lib/gitlab/dependency_linker/composer_json_linker.rb | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/lib/gitlab/dependency_linker.rb b/lib/gitlab/dependency_linker.rb index 88f4ebedb9f..9cd2fbdfd17 100644 --- a/lib/gitlab/dependency_linker.rb +++ b/lib/gitlab/dependency_linker.rb @@ -4,6 +4,7 @@ module Gitlab GemfileLinker, GemspecLinker, PackageJsonLinker, + ComposerJsonLinker, ].freeze def self.linker(blob_name) diff --git a/lib/gitlab/dependency_linker/composer_json_linker.rb b/lib/gitlab/dependency_linker/composer_json_linker.rb new file mode 100644 index 00000000000..0245bf4077a --- /dev/null +++ b/lib/gitlab/dependency_linker/composer_json_linker.rb @@ -0,0 +1,18 @@ +module Gitlab + module DependencyLinker + class ComposerJsonLinker < PackageJsonLinker + self.file_type = :composer_json + + private + + def link_packages + link_packages_at_key("require", &method(:package_url)) + link_packages_at_key("require-dev", &method(:package_url)) + end + + def package_url(name) + "https://packagist.org/packages/#{name}" if name =~ %r{\A#{REPO_REGEX}\z} + end + end + end +end |