Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
81.25% |
13 / 16 |
|
33.33% |
1 / 3 |
CRAP | |
0.00% |
0 / 1 |
Git | |
81.25% |
13 / 16 |
|
33.33% |
1 / 3 |
5.16 | |
0.00% |
0 / 1 |
readCurrentHead | |
66.67% |
4 / 6 |
|
0.00% |
0 / 1 |
2.15 | |||
readCurrentHash | |
85.71% |
6 / 7 |
|
0.00% |
0 / 1 |
2.01 | |||
readCurrentVersion | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
1 |
1 | <?php |
2 | |
3 | /** |
4 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
5 | **/ |
6 | |
7 | namespace BO\Slim; |
8 | |
9 | /** |
10 | * Helper for GIT integration |
11 | * |
12 | */ |
13 | class Git |
14 | { |
15 | public static function readCurrentHead() |
16 | { |
17 | $headString = "no version control"; |
18 | $githead = \App::APP_PATH . '/.git/HEAD'; |
19 | if (is_readable($githead)) { |
20 | $headString = trim(fgets(fopen($githead, 'r'))); |
21 | $headString = preg_replace('#^.* ([^\s]+)$#', '$1', $headString); |
22 | } |
23 | return $headString; |
24 | } |
25 | |
26 | public static function readCurrentHash() |
27 | { |
28 | $githash = false; |
29 | $headString = static::readCurrentHead(); |
30 | $githashFile = \App::APP_PATH . '/.git/' . $headString; |
31 | if (is_readable($githashFile)) { |
32 | $githash = trim(fgets(fopen($githashFile, 'r'))); |
33 | } else { |
34 | $githash = $headString; |
35 | } |
36 | return $githash; |
37 | } |
38 | |
39 | public static function readCurrentVersion() |
40 | { |
41 | $headString = static::readCurrentHead(); |
42 | $headString = preg_replace('#refs/heads/#', '', $headString); |
43 | return $headString; |
44 | } |
45 | } |