|
MediaWiki master
|
Fetch status information from a local git repository. More...
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 MW_INSTALL_PATH. | |
Protected Member Functions | |
| getRemoteUrl () | |
| Get the URL of the remote origin. | |
Protected Attributes | |
| string null | $basedir |
| Location of the .git directory. | |
| array | $cache = [] |
| Cached git information. | |
| string null | $cacheFile |
| Path to JSON cache file for pre-computed git information. | |
| string | $repoDir |
| Location of the repository. | |
Static Protected Attributes | |
| static self null | $repo = null |
| Singleton for the repo at $IP. | |
Fetch status information from a local git repository.
This is used by Special:Version. It can also be used by developers in their LocalSettings.php to ease testing of a branch you work on for a longer period of time. For example:
if ( GitInfo::currentBranch() === 'myrewriteproject' ) {
}
Definition at line 33 of file GitInfo.php.
| MediaWiki\Utils\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 73 of file GitInfo.php.
References $path, MediaWiki\Utils\GitInfo\$repoDir, MediaWiki\Utils\GitInfo\cacheIsComplete(), and MediaWiki\MediaWikiServices\getInstance().
| MediaWiki\Utils\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.
Definition at line 364 of file GitInfo.php.
Referenced by MediaWiki\Utils\GitInfo\__construct(), and MediaWiki\Utils\GitInfo\precomputeValues().
|
static |
Definition at line 420 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\repo().
| MediaWiki\Utils\GitInfo::getCurrentBranch | ( | ) |
Get the name of the current branch, or HEAD if not found.
Definition at line 282 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\getHead().
Referenced by MediaWiki\Utils\GitInfo\precomputeValues().
| MediaWiki\Utils\GitInfo::getHead | ( | ) |
Get the HEAD of the repo (without any opening "ref: ")
Definition at line 184 of file GitInfo.php.
Referenced by MediaWiki\Utils\GitInfo\getCurrentBranch(), MediaWiki\Utils\GitInfo\getHeadCommitDate(), MediaWiki\Utils\GitInfo\getHeadSHA1(), and MediaWiki\Utils\GitInfo\precomputeValues().
| MediaWiki\Utils\GitInfo::getHeadCommitDate | ( | ) |
Get the commit date of HEAD entry of the git code repository.
Definition at line 240 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\getHead(), MediaWiki\MainConfigNames\GitBin, and MediaWiki\Message\Message\isDisabled().
Referenced by MediaWiki\Utils\GitInfo\precomputeValues().
| MediaWiki\Utils\GitInfo::getHeadSHA1 | ( | ) |
Get the SHA1 for the current HEAD of the repo.
Definition at line 208 of file GitInfo.php.
References $matches, and MediaWiki\Utils\GitInfo\getHead().
Referenced by MediaWiki\Utils\GitInfo\getHeadViewUrl(), and MediaWiki\Utils\GitInfo\precomputeValues().
| MediaWiki\Utils\GitInfo::getHeadViewUrl | ( | ) |
Get an URL to a web viewer link to the HEAD revision.
Definition at line 300 of file GitInfo.php.
References $matches, MediaWiki\Utils\GitInfo\$repo, $url, MediaWiki\Utils\GitInfo\getHeadSHA1(), and MediaWiki\Utils\GitInfo\getRemoteUrl().
|
protected |
Get the URL of the remote origin.
Definition at line 326 of file GitInfo.php.
References $url.
Referenced by MediaWiki\Utils\GitInfo\getHeadViewUrl(), and MediaWiki\Utils\GitInfo\precomputeValues().
|
static |
Definition at line 412 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\repo().
|
static |
Definition at line 428 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\repo().
|
static |
Check if a string looks like a hex encoded SHA1 hash.
| string | $str | The string to check |
Definition at line 175 of file GitInfo.php.
| MediaWiki\Utils\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.
Definition at line 381 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\cacheIsComplete(), MediaWiki\Utils\GitInfo\getCurrentBranch(), MediaWiki\Utils\GitInfo\getHead(), MediaWiki\Utils\GitInfo\getHeadCommitDate(), MediaWiki\Utils\GitInfo\getHeadSHA1(), MediaWiki\Utils\GitInfo\getRemoteUrl(), and wfMkdirParents().
|
static |
Get the singleton for the repo at MW_INSTALL_PATH.
Definition at line 162 of file GitInfo.php.
References MediaWiki\Utils\GitInfo\$repo.
Referenced by MediaWiki\Utils\GitInfo\currentBranch(), MediaWiki\Utils\GitInfo\headSHA1(), and MediaWiki\Utils\GitInfo\headViewUrl().
|
protected |
Location of the .git directory.
Definition at line 39 of file GitInfo.php.
|
protected |
Cached git information.
Definition at line 48 of file GitInfo.php.
|
protected |
Path to JSON cache file for pre-computed git information.
Definition at line 45 of file GitInfo.php.
|
staticprotected |
Singleton for the repo at $IP.
Definition at line 36 of file GitInfo.php.
Referenced by MediaWiki\Utils\GitInfo\getHeadViewUrl(), and MediaWiki\Utils\GitInfo\repo().
|
protected |
Location of the repository.
Definition at line 42 of file GitInfo.php.
Referenced by MediaWiki\Utils\GitInfo\__construct().