11 if ( !
mkdir( self::$tempDir ) ) {
12 self::$tempDir =
null;
13 throw new Exception(
'Unable to create temporary directory' );
15 mkdir( self::$tempDir .
'/gitrepo' );
16 mkdir( self::$tempDir .
'/gitrepo/1' );
17 mkdir( self::$tempDir .
'/gitrepo/2' );
18 mkdir( self::$tempDir .
'/gitrepo/3' );
19 mkdir( self::$tempDir .
'/gitrepo/1/.git' );
20 mkdir( self::$tempDir .
'/gitrepo/1/.git/refs' );
21 mkdir( self::$tempDir .
'/gitrepo/1/.git/refs/heads' );
23 "ref: refs/heads/master\n" );
25 "0123456789012345678901234567890123abcdef\n" );
27 "abcdef6789012345678901234567890123456789 refs/heads/master\n" );
29 "gitdir: ../1/.git\n" );
31 'gitdir: ' . self::$tempDir .
"/gitrepo/1/.git\n" );
35 if ( self::$tempDir ) {
42 $this->
setMwGlobals(
'wgGitInfoCacheDirectory', __DIR__ .
'/../data/gitinfo' );
48 $this->
assertEquals(
'0123456789abcdef0123456789abcdef01234567',
64 $dir =
$GLOBALS[
'IP'] .
'/testMissingJsonData';
71 $this->
assertEquals(
false, $fixture->getHeadCommitDate() );
72 $this->
assertEquals(
false, $fixture->getCurrentBranch() );
73 $this->
assertEquals(
false, $fixture->getHeadViewUrl() );
76 $this->
assertTrue( $fixture->cacheIsComplete() );
80 $dir = self::$tempDir .
'/gitrepo/1';
83 $this->
assertEquals(
'refs/heads/master', $fixture->getHead() );
84 $this->
assertEquals(
'0123456789012345678901234567890123abcdef', $fixture->getHeadSHA1() );
88 $dir = self::$tempDir .
'/gitrepo/2';
91 $this->
assertEquals(
'refs/heads/master', $fixture->getHead() );
92 $this->
assertEquals(
'0123456789012345678901234567890123abcdef', $fixture->getHeadSHA1() );
96 $dir = self::$tempDir .
'/gitrepo/3';
99 $this->
assertEquals(
'refs/heads/master', $fixture->getHead() );
100 $this->
assertEquals(
'0123456789012345678901234567890123abcdef', $fixture->getHeadSHA1() );
104 $dir = self::$tempDir .
'/gitrepo/1';
105 unlink( self::$tempDir .
'/gitrepo/1/.git/refs/heads/master' );
106 $fixture =
new GitInfo( $dir );
108 $this->
assertEquals(
'refs/heads/master', $fixture->getHead() );
109 $this->
assertEquals(
'abcdef6789012345678901234567890123456789', $fixture->getHeadSHA1() );
and that you know you can do these things To protect your we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights These restrictions translate to certain responsibilities for you if you distribute copies of the or if you modify it For if you distribute copies of such a whether gratis or for a you must give the recipients all the rights that you have You must make sure that receive or can get the source code And you must show them these terms so they know their rights We protect your rights with two and(2) offer you this license which gives you legal permission to copy
wfTempDir()
Tries to get the system directory for temporary files.
wfRandomString( $length=32)
Get a random string containing a number of pseudo-random hex characters.
wfRecursiveRemoveDir( $dir)
Remove a directory and all its content.
static setUpBeforeClass()
assertValidGitInfo(GitInfo $gitInfo)
static tearDownAfterClass()
getHead()
Get the HEAD of the repo (without any opening "ref: ")
getHeadCommitDate()
Get the commit date of HEAD entry of the git code repository.
cacheIsComplete()
Check to see if the current cache is fully populated.
getHeadViewUrl()
Get an URL to a web viewer link to the HEAD revision.
getHeadSHA1()
Get the SHA1 for the current HEAD of the repo.
getCurrentBranch()
Get the name of the current branch, or HEAD if not found.