public static function getRevision($length = 10)
    {
        $revision = Cache::call("revision", function() {
            $path = static::path(".git");
            if (!is_dir($path)) {
                return;
            }

            $head = $path . "/HEAD";
            if (!file_exists($head)) {
                return;
            }

            $data = File::getContents($head);
            if (!preg_match("/ref: ([^\s]+)\s/", $data, $matches)) {
                return;
            }
            $ref = $path . "/" . $matches[1];
            if (!file_exists($ref)) {
                return;
            }

            return File::getContents($ref);
        });

        if ($length > 0) {
            return substr($revision, 0, $length);
        } else {
            return $revision;
        }
    }
public static function getRevision($length = 10)
    {
        $revision = Cache::call("revision", function() {
            $path = static::path(".git");
            if (!is_dir($path)) {
                return;
            }

            $head = $path . "/HEAD";
            if (!file_exists($head)) {
                return;
            }

            $data = File::getContents($head);
            if (!preg_match("/ref: ([^\s]+)\s/", $data, $matches)) {
                return;
            }
            $ref = $path . "/" . $matches[1];
            if (!file_exists($ref)) {
                return;
            }

            return File::getContents($ref);
        });

        if ($length > 0) {
            return substr($revision, 0, $length);
        } else {
            return $revision;
        }
    }
public static function getRevision ( $ length = 10 ) { $ revision = Cache :: call ( "revision" , function ( ) { $ path = static :: path ( ".git" ) ; if ( ! is_dir ( $ path ) ) { return ; } $ head = $ path . "/HEAD" ; if ( ! file_exists ( $ head ) ) { return ; } $ data = File :: getContents ( $ head ) ; if ( ! preg_match ( "/ref: ([^\s]+)\s/" , $ data , $ matches ) ) { return ; } $ ref = $ path . "/" . $ matches [ 1 ] ; if ( ! file_exists ( $ ref ) ) { return ; } return File :: getContents ( $ ref ) ; } ) ; if ( $ length > 0 ) { return substr ( $ revision , 0 , $ length ) ; } else { return $ revision ; } }
Get the revision number from the local git clone data.

@param int $length The length of the revision hash to return

@return string|void
Get the revision number from the local git clone data .