private function collectInformation(): void
    {
        if (!$this->collectVersionInfo) {
            return;
        }

        $basePath = $this->basePath;
        [$code, $ret,] = Sys::run('git log --pretty="%H" -n1 HEAD', $basePath);

        if ($code !== 0) {
            throw new \RuntimeException(
                'Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.'
            );
        }

        $this->version = \trim($ret);

        [$code, $ret,] = Sys::run('git log -n1 --pretty=%ci HEAD', $basePath);

        if ($code !== 0) {
            throw new \RuntimeException(
                'Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.'
            );
        }

        $this->versionDate = new \DateTime(\trim($ret));
        $this->versionDate->setTimezone(new \DateTimeZone('UTC'));

        // 获取到最新的 tag
        [$code, $ret,] = Sys::run('git describe --tags --exact-match HEAD', $basePath);
        if ($code === 0) {
            $this->version = \trim($ret);
        } else {
            [$code1, $ret,] = Sys::run('git branch', $basePath);

            if ($code1 === 0) {
                $this->branchAliasVersion = \explode("\n", \trim($ret, "* \n"), 2)[0];
            }
        }
    }
private function collectInformation(): void
    {
        if (!$this->collectVersionInfo) {
            return;
        }

        $basePath = $this->basePath;
        [$code, $ret,] = Sys::run('git log --pretty="%H" -n1 HEAD', $basePath);

        if ($code !== 0) {
            throw new \RuntimeException(
                'Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.'
            );
        }

        $this->version = \trim($ret);

        [$code, $ret,] = Sys::run('git log -n1 --pretty=%ci HEAD', $basePath);

        if ($code !== 0) {
            throw new \RuntimeException(
                'Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.'
            );
        }

        $this->versionDate = new \DateTime(\trim($ret));
        $this->versionDate->setTimezone(new \DateTimeZone('UTC'));

        // 获取到最新的 tag
        [$code, $ret,] = Sys::run('git describe --tags --exact-match HEAD', $basePath);
        if ($code === 0) {
            $this->version = \trim($ret);
        } else {
            [$code1, $ret,] = Sys::run('git branch', $basePath);

            if ($code1 === 0) {
                $this->branchAliasVersion = \explode("\n", \trim($ret, "* \n"), 2)[0];
            }
        }
    }
private function collectInformation ( ) : void { if ( ! $ this -> collectVersionInfo ) { return ; } $ basePath = $ this -> basePath ; [ $ code , $ ret , ] = Sys :: run ( 'git log --pretty="%H" -n1 HEAD' , $ basePath ) ; if ( $ code !== 0 ) { throw new \ RuntimeException ( 'Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.' ) ; } $ this -> version = \ trim ( $ ret ) ; [ $ code , $ ret , ] = Sys :: run ( 'git log -n1 --pretty=%ci HEAD' , $ basePath ) ; if ( $ code !== 0 ) { throw new \ RuntimeException ( 'Can\'t run git log. You must ensure to run compile from git repository clone and that git binary is available.' ) ; } $ this -> versionDate = new \ DateTime ( \ trim ( $ ret ) ) ; $ this -> versionDate -> setTimezone ( new \ DateTimeZone ( 'UTC' ) ) ; // 获取到最新的 tag [ $ code , $ ret , ] = Sys :: run ( 'git describe --tags --exact-match HEAD' , $ basePath ) ; if ( $ code === 0 ) { $ this -> version = \ trim ( $ ret ) ; } else { [ $ code1 , $ ret , ] = Sys :: run ( 'git branch' , $ basePath ) ; if ( $ code1 === 0 ) { $ this -> branchAliasVersion = \ explode ( "\n" , \ trim ( $ ret , "* \n" ) , 2 ) [ 0 ] ; } } }
auto collect project information by git log
@throws \RuntimeException
@throws \Exception
auto collect project information by git log