1 | <?php |
||
23 | final class VcsVersionInfo |
||
24 | { |
||
25 | /** |
||
26 | * @var \nochso\Omni\VersionInfo |
||
27 | */ |
||
28 | private $version; |
||
29 | /** |
||
30 | * @var string |
||
31 | */ |
||
32 | private $repositoryRoot; |
||
33 | |||
34 | /** |
||
35 | * @param string $name Package or application name. |
||
36 | * @param string $fallBackVersion Version to fall back to if no repository info was found. |
||
37 | * @param string $repositoryRoot Path the VCS repository root (e.g. folder that contains ".git", ".hg", etc.) |
||
38 | * @param string $infoFormat Optional format to use for `getInfo`. Defaults to `self::INFO_FORMAT_DEFAULT` |
||
39 | */ |
||
40 | public function __construct($name, $fallBackVersion = null, $repositoryRoot = '."', $infoFormat = VersionInfo::INFO_FORMAT_DEFAULT) |
||
49 | |||
50 | /** |
||
51 | * @return string |
||
52 | */ |
||
53 | public function getInfo() |
||
57 | |||
58 | /** |
||
59 | * @return string |
||
60 | */ |
||
61 | public function getVersion() |
||
65 | |||
66 | /** |
||
67 | * @return string |
||
68 | */ |
||
69 | public function getName() |
||
73 | |||
74 | private function extractTag() |
||
82 | |||
83 | /** |
||
84 | * @return null|string |
||
85 | */ |
||
86 | private function readGit() |
||
99 | |||
100 | /** |
||
101 | * @return null|string |
||
102 | */ |
||
103 | private function readMercurial() |
||
137 | |||
138 | /** |
||
139 | * execEscaped executes a command with automatically escaped parameters. |
||
140 | * |
||
141 | * @param string $cmdFormat |
||
142 | * @param array ...$params |
||
143 | * |
||
144 | * @see sprintf() |
||
145 | * |
||
146 | * @return string[] Only lines with content after trimming are returned. |
||
147 | */ |
||
148 | private function execEscaped($cmdFormat, ...$params) |
||
155 | } |
||
156 |