forked from llaville/umlwriter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphar-manifest.php
38 lines (29 loc) · 958 Bytes
/
phar-manifest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env php
<?php
/**
* Credits to Sebastian Bergmann (original author)
*/
print 'bartlett/umlwriter: <info>';
$tag = exec('git describe --tags 2>&1');
if (strpos($tag, '-') === false && strpos($tag, 'No names found') === false) {
print $tag;
} else {
$branch = exec('git rev-parse --abbrev-ref HEAD');
$hash = exec('git log -1 --format="%H"');
print $branch . '@' . $hash;
}
print "</info>\n";
$lock = json_decode(file_get_contents(__DIR__ . '/composer.lock'));
$packages = function ($package) {
print $package->name . ': <info>' . $package->version;
if (!preg_match('/^[v= ]*(([0-9]+)(\\.([0-9]+)(\\.([0-9]+)(-([0-9]+))?(-?([a-zA-Z-+][a-zA-Z0-9\\.\\-:]*)?)?)?)?)$/', $package->version)) {
print '@' . $package->source->reference;
}
print "</info>\n";
};
foreach ($lock->packages as $package) {
$packages($package);
}
foreach ($lock->{'packages-dev'} as $package) {
$packages($package);
}