BlueSpice MediaWiki REL1_27
 All Classes Namespaces Files Functions Variables Groups Pages
GitInfo Class Reference

Public Member Functions

 __construct ($repoDir, $usePrecomputed=true)
 
 getHead ()
 
 getHeadSHA1 ()
 
 getHeadCommitDate ()
 
 getCurrentBranch ()
 
 getHeadViewUrl ()
 
 cacheIsComplete ()
 
 precomputeValues ()
 

Static Public Member Functions

static repo ()
 
static isSHA1 ($str)
 
static headSHA1 ()
 
static currentBranch ()
 
static headViewUrl ()
 

Protected Member Functions

 getRemoteUrl ()
 

Static Protected Member Functions

static getCacheFilePath ($repoDir)
 
static getViewers ()
 

Protected Attributes

 $basedir
 
 $cacheFile
 
 $cache = []
 

Static Protected Attributes

static $repo = null
 

Constructor & Destructor Documentation

GitInfo::__construct (   $repoDir,
  $usePrecomputed = true 
)
Parameters
string$repoDirThe root directory of the repo where .git can be found
bool$usePrecomputedUse precomputed information if available
See Also
precomputeValues

Member Function Documentation

GitInfo::cacheIsComplete ( )

Check to see if the current cache is fully populated.

Note: This method is public only to make unit testing easier. There's really no strong reason that anything other than a test should want to call this method.

Returns
bool True if all expected cache keys exist, false otherwise
static GitInfo::currentBranch ( )
static
See Also
self::getCurrentBranch
Returns
string
static GitInfo::getCacheFilePath (   $repoDir)
staticprotected

Compute the path to the cache file for a given directory.

Parameters
string$repoDirThe root directory of the repo where .git can be found
Returns
string Path to GitInfo cache file in $wgGitInfoCacheDirectory or fallback in the extension directory itself
Since
1.24
GitInfo::getCurrentBranch ( )

Get the name of the current branch, or HEAD if not found

Returns
string|bool The branch name, HEAD, or false
GitInfo::getHead ( )

Get the HEAD of the repo (without any opening "ref: ")

Returns
string|bool The HEAD (git reference or SHA1) or false
GitInfo::getHeadCommitDate ( )

Get the commit date of HEAD entry of the git code repository

Since
1.22
Returns
int|bool Commit date (UNIX timestamp) or false
GitInfo::getHeadSHA1 ( )

Get the SHA1 for the current HEAD of the repo

Returns
string|bool A SHA1 or false
GitInfo::getHeadViewUrl ( )

Get an URL to a web viewer link to the HEAD revision.

Returns
string|bool String if a URL is available or false otherwise
GitInfo::getRemoteUrl ( )
protected

Get the URL of the remote origin.

Returns
string|bool String if a URL is available or false otherwise.
static GitInfo::getViewers ( )
staticprotected

Gets the list of repository viewers

Returns
array
static GitInfo::headSHA1 ( )
static
See Also
self::getHeadSHA1
Returns
string
static GitInfo::headViewUrl ( )
static
See Also
self::getHeadViewUrl()
Returns
bool|string
static GitInfo::isSHA1 (   $str)
static

Check if a string looks like a hex encoded SHA1 hash

Parameters
string$strThe string to check
Returns
bool Whether or not the string looks like a SHA1
GitInfo::precomputeValues ( )

Precompute and cache git information.

Creates a JSON file in the cache directory associated with this GitInfo instance. This cache file will be used by subsequent GitInfo objects referencing the same directory to avoid needing to examine the .git directory again.

Since
1.24
static GitInfo::repo ( )
static

Get the singleton for the repo at $IP

Returns
GitInfo

Member Data Documentation

GitInfo::$basedir
protected

Location of the .git directory

GitInfo::$cache = []
protected

Cached git information.

GitInfo::$cacheFile
protected

Path to JSON cache file for pre-computed git information.

GitInfo::$repo = null
staticprotected

Singleton for the repo at $IP


The documentation for this class was generated from the following file: