MediaWiki  1.23.2
GitInfo Class Reference

Public Member Functions

 __construct ( $dir)
 
 getCurrentBranch ()
 Return the name of the current branch, or HEAD if not found. More...
 
 getHead ()
 Return the HEAD of the repo (without any opening "ref: ") More...
 
 getHeadCommitDate ()
 Return the commit date of HEAD entry of the git code repository. More...
 
 getHeadSHA1 ()
 Return the SHA1 for the current HEAD of the repo. More...
 
 getHeadViewUrl ()
 Get an URL to a web viewer link to the HEAD revision. More...
 

Static Public Member Functions

static currentBranch ()
 
static headSHA1 ()
 
static headViewUrl ()
 
static isSHA1 ( $str)
 Check if a string looks like a hex encoded SHA1 hash. More...
 
static repo ()
 Return a singleton for the repo at $IP. More...
 

Static Protected Member Functions

static getViewers ()
 Gets the list of repository viewers. More...
 

Protected Attributes

 $basedir
 Location of the .git directory. More...
 

Static Protected Attributes

static $repo = null
 Singleton for the repo at $IP. More...
 

Static Private Attributes

static $viewers = false
 Map of repo URLs to viewer URLs. More...
 

Detailed Description

Definition at line 26 of file GitInfo.php.

Constructor & Destructor Documentation

◆ __construct()

GitInfo::__construct (   $dir)
Parameters
string$dirThe root directory of the repo where the .git dir can be found

Definition at line 46 of file GitInfo.php.

References $dir, and $path.

Member Function Documentation

◆ currentBranch()

static GitInfo::currentBranch ( )
static
See also
self::getCurrentBranch
Returns
string

Definition at line 224 of file GitInfo.php.

References repo().

Referenced by MWDebug\getDebugInfo().

◆ getCurrentBranch()

GitInfo::getCurrentBranch ( )

Return the name of the current branch, or HEAD if not found.

Returns
string The branch name, HEAD, or false

Definition at line 152 of file GitInfo.php.

References getHead().

◆ getHead()

GitInfo::getHead ( )

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

Returns
string The HEAD

Definition at line 84 of file GitInfo.php.

Referenced by getCurrentBranch(), and getHeadSHA1().

◆ getHeadCommitDate()

GitInfo::getHeadCommitDate ( )

Return the commit date of HEAD entry of the git code repository.

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

Definition at line 129 of file GitInfo.php.

References array(), global, wfEscapeShellArg(), and wfShellExec().

◆ getHeadSHA1()

GitInfo::getHeadSHA1 ( )

Return the SHA1 for the current HEAD of the repo.

Returns
string A SHA1 or false

Definition at line 104 of file GitInfo.php.

References getHead().

Referenced by getHeadViewUrl().

◆ getHeadViewUrl()

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.

Definition at line 166 of file GitInfo.php.

References $matches, $repo, array(), as, getHeadSHA1(), wfRestoreWarnings(), and wfSuppressWarnings().

◆ getViewers()

static GitInfo::getViewers ( )
staticprotected

Gets the list of repository viewers.

Returns
array

Definition at line 240 of file GitInfo.php.

References $viewers, array(), global, and wfRunHooks().

◆ headSHA1()

static GitInfo::headSHA1 ( )
static
See also
self::getHeadSHA1
Returns
string

Definition at line 216 of file GitInfo.php.

References repo().

Referenced by MWDebug\getDebugInfo().

◆ headViewUrl()

static GitInfo::headViewUrl ( )
static
See also
self::getHeadViewUrl()
Returns
bool|string

Definition at line 232 of file GitInfo.php.

References repo().

Referenced by MWDebug\getDebugInfo().

◆ isSHA1()

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

Definition at line 76 of file GitInfo.php.

◆ repo()

static GitInfo::repo ( )
static

Return a singleton for the repo at $IP.

Returns
GitInfo

Definition at line 62 of file GitInfo.php.

References $IP, $repo, and global.

Referenced by currentBranch(), headSHA1(), and headViewUrl().

Member Data Documentation

◆ $basedir

GitInfo::$basedir
protected

Location of the .git directory.

Definition at line 36 of file GitInfo.php.

◆ $repo

GitInfo::$repo = null
staticprotected

Singleton for the repo at $IP.

Definition at line 31 of file GitInfo.php.

Referenced by getHeadViewUrl(), and repo().

◆ $viewers

GitInfo::$viewers = false
staticprivate

Map of repo URLs to viewer URLs.

Access via static method getViewers().

Definition at line 41 of file GitInfo.php.

Referenced by getViewers().


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