Commit graph

9 commits

Author SHA1 Message Date
Thiemo Kreuz
e4272518f7 tests: Replace PHPUnit's loose assertEquals(false) with assertFalse()
assertEquals( false, … ) still succeeds when the actual value is 0, null,
an empty string, even an empty array. All these should be reported as a
failure, I would argue.

Note this patch previously also touched assertSame( false ). I reverted
these. The only benefit would have been consistency within this codebase,
but there is no strict reason to prefer one over the other. assertFalse()
and assertSame( false ) are functionally identical.

Change-Id: Ic5f1c7d504e7249002d3184520012e03313137b4
2019-10-04 00:30:36 +00:00
Tim Starling
11278f848d Allow tests to run with a non-writable source tree
It's insecure to allow apps to modify their own source, that's how file
write vulnerabilities escalate to code execution.

Change-Id: I0f79b2b7c7502405a62dcb176d8be4633ce4eda5
2018-08-30 10:48:50 +10:00
Seb35
125f83234e Improve GitInfo for reading packed refs
GitInfo only reads branches in files /refs/heads/*; it should also
read those in /.git/packed-refs.

There are 4 tests in this commit to test this new "feature" and add some
code coverage to other methods. Given this class tests Git behaviour and
MediaWiki itself is versioned with Git, the test data are created during
the tests and removed at the end to avoid interference with Git as CVS.

Bug: T155747
Change-Id: Icccdf3ec797788582f836e2d8e267a1d714d50dc
2017-10-02 03:47:33 +00:00
Reedy
de5e6e6669 phpcs.xml: Escape . in exclude-pattern
And fix errors in a file that was previously being excluded.

Bug: T129664
Change-Id: I60161b4037ca122ccd2f0730a4b4aa59d878e459
2017-07-23 00:46:12 +00:00
umherirrender
34fe90ac52 Remove empty lines at end of functions
It looks like there is something missing after the last statement
Also remove some other empty lines at begin of functions, ifs or loops
while at these files

Change-Id: Ib00b5cfd31ca4dcd0c32ce33754d3c80bae70641
2016-11-05 11:55:10 +01:00
Kunal Mehta
a5ed38dc54 GitInfo: Allow cache to be in the extension directory itself
For ExtensionDistributor to provide git metadata, we need to be able to
store the cache file inside the extension directory itself. The GitInfo
class will now first check if the $wgGitInfoCacheDirectory is populated,
otherwise it will fallback to "$extensionDir/gitinfo.json".

Bug: T122769
Change-Id: Ib3457589ca6899925ae4610cfcdae22af8eaaaeb
2016-01-06 14:41:36 -08:00
umherirrender
748721a334 Fix GitInfoTest::testValidJsonData on windows
GitInfo.php is replacing DIRECTORY_SEPARATOR by '-'.
On windows this is \, which was not set in the tests.

1) GitInfoTest::testValidJsonData
Failed asserting that false is true.

Change-Id: I1871c342b61a335b59a98755d8b824cc58c1543e
2014-09-30 20:44:45 +00:00
Bryan Davis
b6d18ab9f7 Fix GitInfo cache file path computation and storage location
Depending on the configuration used in LocalSettings.php, $IP can be
changed between the time that configuration is loaded and the wiki
runtime by logic in WebStart.php. Attempt to mitigate the effects of
such changes on the cache file name computation by canonicalizing both
$IP and the path using PHP's realpath() function.

Related but distinct is the possible need to configure the canonical
location for finding cache files on disk separately from
$wgCacheDirectory. This change introduces a new configuration variable
named $wgGitInfoCacheDirectory that can be set to a path that diverges
from the default location of $wgCacheDirectory/gitinfo. This will be
useful in the WMF cluster where $wgCacheDirectory points to a directory
that is not managed by the deployment system.

Finally add wfDebugLog logging to make tracking down issues such as
miscomputed cache paths easier.

Bug: 53972
Change-Id: Iceb9e1ce8d3b4bb08f89fa6ec5d5e7392aaafd46
2014-07-08 16:36:10 +00:00
Bryan Davis
71fc32c303 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
2014-05-05 23:50:12 +00:00