Skip to content

Commit 4bc047b

Browse files
committed
Added Drupal packages support.
Drupal packages can have following endpoints: * https://git.drupalcode.org/project/metatag.git * git@git.drupal.org:project/metatag.git This PR adds support for Drupal contributed modules. To support the Drupal 8, a contrib module can have a version like `8.x-1.0`. Drupal packagist script converts it to semver `1.0.0` to make it compatible with composer package versions. Right now only Drupal 8 modules can be installed using composer that is why the fix is specific to Druapl 8 version. Here is the sample output: | Production Changes | From | To | Compare | |----------------------------|---------|----------|------------------------------------------------------------------------------| | drupal/metatag | 1.9.0 | 1.10.0 | [...](https://git.drupalcode.org/project/metatag/compare/8.x-1.9...8.x-1.10) |
1 parent 817bb8f commit 4bc047b

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

composer-lock-diff

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -222,6 +222,9 @@ function getSourceRepoType($url) {
222222
if (preg_match('/^git@gitlab\..+:.+\.git$/', $url)) {
223223
return 'gitlab';
224224
}
225+
if (preg_match('/^git@git\.drupal\..+:.+\.git$/', $url)) {
226+
return 'drupal';
227+
}
225228

226229
if (! preg_match('/^http/i', $url)) {
227230
return 'unknown';
@@ -235,6 +238,8 @@ function getSourceRepoType($url) {
235238
return 'bitbucket';
236239
} elseif (strpos($host, 'gitlab') !== false) {
237240
return 'gitlab';
241+
} elseif (strpos($host, 'drupalcode') !== false) {
242+
return 'drupal';
238243
}
239244

240245
return 'unknown';
@@ -268,6 +273,11 @@ function formatCompareGitlab($url, $from, $to) {
268273
return sprintf('%s/compare/%s...%s', $url, urlencode($from), urlencode($to));
269274
}
270275

276+
function formatCompareDrupal($url, $from, $to) {
277+
$url = preg_replace('/\.git$/', '', $url);
278+
return sprintf('%s/compare/8.x-%s...8.x-%s', $url, substr(urlencode($from), 0, -2), substr(urlencode($to), 0, -2));
279+
}
280+
271281
function parseOpts() {
272282
$given = getopt('hp:', array('path:', 'from:', 'to:', 'md', 'json', 'pretty', 'no-links', 'only-prod', 'only-dev', 'help'));
273283

0 commit comments

Comments
 (0)