Support precomputed data in GitInfo
authorBryan Davis <bd808@wikimedia.org>
Mon, 28 Apr 2014 19:50:03 +0000 (13:50 -0600)
committerOri.livneh <ori@wikimedia.org>
Mon, 5 May 2014 23:50:12 +0000 (23:50 +0000)
commit71fc32c303a0f0ab41368739684975ca4f600c36
tree8e7e1fb8b216e454a1403e7c8cb8a04a3610fa73
parented945112a8640fcaefa0128456602893294aee31
Support precomputed data in GitInfo

Support reading git repository information from a JSON file in the cache
directory. When present, this file serves to provide information needed
by getHead, getHeadSHA1, getHeadCommitDate, getCurrentBranch and a new
getRemoteUrl method. A GitInfo::precomputeValues method is also provided
which can generate the cache file for a given GitInfo instance.

This support can be combined with a deployment step to reduce the need
to repeatedly gather information from the .git files/git binary. It also
allows computing information that can be lost when directory structures
differ between deployment staging hosts and hosts running MediaWiki.

This change also adds memoization of computed values for a given GitInfo
instance which may provide a small performance boost even for
deployments which are not using precomputed cache files.

Bug: 53972
Change-Id: I66e058acc5a71e5d82644f85d819f49d6ee9d1e6
includes/GitInfo.php
tests/phpunit/data/gitinfo/info-testValidJsonData.json [new file with mode: 0644]
tests/phpunit/includes/GitInfoTest.php [new file with mode: 0644]