Formatter/GitDescribeFormatter.php
public function format(Version $version)
    {
        if (preg_match('/^(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) {
            if ((int) $matches[1] != 0) {
                // we are not on TAG commit, add "dev" and git commit hash as pre release part
                $version = $version->withPreRelease(array('dev', $matches[2]));
            } else {
                $version = $version->withPreRelease(array());
            }
        }

        if (preg_match('/^(.*)-(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) {
            if ((int) $matches[2] != 0) {
                // we are not on TAG commit, add "dev" and git commit hash as pre release part
                if (empty($matches[1])) {
                    $version = $version->withPreRelease(array('dev', $matches[3]));
                } else {
                    $version = $version->withPreRelease(array_merge(explode('.', trim($matches[1], '-')), array('dev', $matches[3])));
                }
            } else {
                if (empty($matches[1])) {
                    $version = $version->withPreRelease(array());
                } else {
                    $version = $version->withPreRelease(trim($matches[1], '-'));
                }
            }
        }

        return $version;
    }
public function format(Version $version)
    {
        if (preg_match('/^(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) {
            if ((int) $matches[1] != 0) {
                // we are not on TAG commit, add "dev" and git commit hash as pre release part
                $version = $version->withPreRelease(array('dev', $matches[2]));
            } else {
                $version = $version->withPreRelease(array());
            }
        }

        if (preg_match('/^(.*)-(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/', $version->getPreRelease(), $matches)) {
            if ((int) $matches[2] != 0) {
                // we are not on TAG commit, add "dev" and git commit hash as pre release part
                if (empty($matches[1])) {
                    $version = $version->withPreRelease(array('dev', $matches[3]));
                } else {
                    $version = $version->withPreRelease(array_merge(explode('.', trim($matches[1], '-')), array('dev', $matches[3])));
                }
            } else {
                if (empty($matches[1])) {
                    $version = $version->withPreRelease(array());
                } else {
                    $version = $version->withPreRelease(trim($matches[1], '-'));
                }
            }
        }

        return $version;
    }
public function format ( Version $ version ) { if ( preg_match ( '/^(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/' , $ version -> getPreRelease ( ) , $ matches ) ) { if ( ( int ) $ matches [ 1 ] != 0 ) { // we are not on TAG commit, add "dev" and git commit hash as pre release part $ version = $ version -> withPreRelease ( array ( 'dev' , $ matches [ 2 ] ) ) ; } else { $ version = $ version -> withPreRelease ( array ( ) ) ; } } if ( preg_match ( '/^(.*)-(\d+)-g([a-fA-F0-9]{7,40})(-dirty)?$/' , $ version -> getPreRelease ( ) , $ matches ) ) { if ( ( int ) $ matches [ 2 ] != 0 ) { // we are not on TAG commit, add "dev" and git commit hash as pre release part if ( empty ( $ matches [ 1 ] ) ) { $ version = $ version -> withPreRelease ( array ( 'dev' , $ matches [ 3 ] ) ) ; } else { $ version = $ version -> withPreRelease ( array_merge ( explode ( '.' , trim ( $ matches [ 1 ] , '-' ) ) , array ( 'dev' , $ matches [ 3 ] ) ) ) ; } } else { if ( empty ( $ matches [ 1 ] ) ) { $ version = $ version -> withPreRelease ( array ( ) ) ; } else { $ version = $ version -> withPreRelease ( trim ( $ matches [ 1 ] , '-' ) ) ; } } } return $ version ; }
Remove hash on tag commit else put dev.hash in prerelease

@param  Version $version
@return Version
Remove hash on tag commit else put dev . hash in prerelease