![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/sebastianfeldmann/git/src/Command/Describe/ |
<?php /** * This file is part of SebastianFeldmann\Git. * * (c) Sebastian Feldmann <[email protected]> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace SebastianFeldmann\Git\Command\Describe; use SebastianFeldmann\Git\Command\Base; /** * Class GetCurrentTag * * @package SebastianFeldmann\Git * @author Sebastian Feldmann <[email protected]> * @link https://github.com/sebastianfeldmann/git * @since Class available since Release 1.0.8 */ class GetMostRecentTag extends Base { /** * @var string */ private $before; /** * Glob to define excluded tags e.g **-RC* to exclude release candidate tags * @var string */ private $exclude; /** * Sets the start point to search for a tag * * @param string $hash * @return \SebastianFeldmann\Git\Command\Describe\GetMostRecentTag */ public function before(string $hash): GetMostRecentTag { $this->before = $hash; return $this; } /** * Glob of tags to ignore e.g. **-RC* to ignore release candidate tags like '1.0.0-RC3' * * @param string $glob * @return \SebastianFeldmann\Git\Command\Describe\GetMostRecentTag */ public function ignore(string $glob): GetMostRecentTag { $this->exclude = $glob; return $this; } /** * Return the command to execute. * * @return string */ protected function getGitCommand(): string { return 'describe --tags --abbrev=0' . $this->tagsToIgnore() . $this->startingPoint(); } /** * Return the --exclude='xxx' option * * @return string */ private function tagsToIgnore(): string { return empty($this->exclude) ? '' : ' --exclude=' . escapeshellarg($this->exclude); } /** * Return the starting point where to start the search for a tag * * @return string */ private function startingPoint(): string { return empty($this->before) ? '' : ' ' . $this->before . '^'; } }