MediaWiki
REL1_24
|
Public Member Functions | |
__construct ($repoDir, $usePrecomputed=true) | |
cacheIsComplete () | |
Check to see if the current cache is fully populated. | |
getCurrentBranch () | |
Get the name of the current branch, or HEAD if not found. | |
getHead () | |
Get the HEAD of the repo (without any opening "ref: ") | |
getHeadCommitDate () | |
Get the commit date of HEAD entry of the git code repository. | |
getHeadSHA1 () | |
Get the SHA1 for the current HEAD of the repo. | |
getHeadViewUrl () | |
Get an URL to a web viewer link to the HEAD revision. | |
precomputeValues () | |
Precompute and cache git information. | |
Static Public Member Functions | |
static | currentBranch () |
static | headSHA1 () |
static | headViewUrl () |
static | isSHA1 ($str) |
Check if a string looks like a hex encoded SHA1 hash. | |
static | repo () |
Get the singleton for the repo at $IP. | |
Protected Member Functions | |
getRemoteUrl () | |
Get the URL of the remote origin. | |
Static Protected Member Functions | |
static | getCacheFilePath ($repoDir) |
Compute the path to the cache file for a given directory. | |
static | getViewers () |
Gets the list of repository viewers. | |
Protected Attributes | |
$basedir | |
Location of the .git directory. | |
$cache = array() | |
Cached git information. | |
$cacheFile | |
Path to JSON cache file for pre-computed git information. | |
Static Protected Attributes | |
static | $repo = null |
Singleton for the repo at $IP. | |
Static Private Attributes | |
static | $viewers = false |
Map of repo URLs to viewer URLs. |
Definition at line 26 of file GitInfo.php.
GitInfo::__construct | ( | $ | repoDir, |
$ | usePrecomputed = true |
||
) |
string | $repoDir | The root directory of the repo where .git can be found |
bool | $usePrecomputed | Use precomputed information if available |
Definition at line 58 of file GitInfo.php.
References $path, cache, cacheIsComplete(), FormatJson\decode(), getCacheFilePath(), and wfDebugLog().
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.
Definition at line 318 of file GitInfo.php.
References cache.
Referenced by __construct(), and precomputeValues().
static GitInfo::currentBranch | ( | ) | [static] |
Definition at line 374 of file GitInfo.php.
References repo().
Referenced by MWDebug\getDebugInfo().
static GitInfo::getCacheFilePath | ( | $ | repoDir | ) | [static, protected] |
Compute the path to the cache file for a given directory.
string | $repoDir | The root directory of the repo where .git can be found |
Definition at line 102 of file GitInfo.php.
Referenced by __construct().
Get the name of the current branch, or HEAD if not found.
Definition at line 233 of file GitInfo.php.
References cache, and getHead().
Referenced by precomputeValues().
GitInfo::getHead | ( | ) |
Get the HEAD of the repo (without any opening "ref: ")
Definition at line 155 of file GitInfo.php.
References cache.
Referenced by getCurrentBranch(), getHeadCommitDate(), getHeadSHA1(), and precomputeValues().
Get the commit date of HEAD entry of the git code repository.
Definition at line 205 of file GitInfo.php.
References array(), cache, getHead(), global, wfEscapeShellArg(), and wfShellExec().
Referenced by precomputeValues().
Get the SHA1 for the current HEAD of the repo.
Definition at line 179 of file GitInfo.php.
References cache, and getHead().
Referenced by getHeadViewUrl(), and precomputeValues().
Get an URL to a web viewer link to the HEAD revision.
Definition at line 251 of file GitInfo.php.
References $matches, $repo, array(), as, getHeadSHA1(), and getRemoteUrl().
GitInfo::getRemoteUrl | ( | ) | [protected] |
Get the URL of the remote origin.
Definition at line 279 of file GitInfo.php.
References as, cache, wfRestoreWarnings(), and wfSuppressWarnings().
Referenced by getHeadViewUrl(), and precomputeValues().
static GitInfo::getViewers | ( | ) | [static, protected] |
Gets the list of repository viewers.
Definition at line 390 of file GitInfo.php.
References $viewers, array(), global, and wfRunHooks().
static GitInfo::headSHA1 | ( | ) | [static] |
Definition at line 366 of file GitInfo.php.
References repo().
Referenced by MWDebug\getDebugInfo().
static GitInfo::headViewUrl | ( | ) | [static] |
Definition at line 382 of file GitInfo.php.
References repo().
Referenced by MWDebug\getDebugInfo().
static GitInfo::isSHA1 | ( | $ | str | ) | [static] |
Check if a string looks like a hex encoded SHA1 hash.
string | $str | The string to check |
Definition at line 146 of file GitInfo.php.
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.
Definition at line 335 of file GitInfo.php.
References cache, cacheIsComplete(), FormatJson\encode(), getCurrentBranch(), getHead(), getHeadCommitDate(), getHeadSHA1(), getRemoteUrl(), wfDebugLog(), and wfMkdirParents().
static GitInfo::repo | ( | ) | [static] |
Get the singleton for the repo at $IP.
Definition at line 132 of file GitInfo.php.
References $IP, $repo, and global.
Referenced by currentBranch(), headSHA1(), and headViewUrl().
GitInfo::$basedir [protected] |
Location of the .git directory.
Definition at line 36 of file GitInfo.php.
Cached git information.
Definition at line 46 of file GitInfo.php.
GitInfo::$cacheFile [protected] |
Path to JSON cache file for pre-computed git information.
Definition at line 41 of file GitInfo.php.
GitInfo::$repo = null [static, protected] |
Singleton for the repo at $IP.
Definition at line 31 of file GitInfo.php.
Referenced by getHeadViewUrl(), and repo().
GitInfo::$viewers = false [static, private] |
Map of repo URLs to viewer URLs.
Access via static method getViewers().
Definition at line 51 of file GitInfo.php.
Referenced by getViewers().