Skip to content

Commit ed04c88

Browse files
committed
Added support for Repository::getDescription
1 parent 57db5e2 commit ed04c88

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/Gitonomy/Git/Repository.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,20 @@ public function getHooks()
338338
return new Hooks($this);
339339
}
340340

341+
/**
342+
* Return the description
343+
*
344+
* @return string The description
345+
*/
346+
public function getDescription()
347+
{
348+
if (!is_file($this->gitDir.'/description')) {
349+
return 'Unnamed repository; edit this file \'description\' to name the repository.';
350+
}
351+
352+
return file_get_contents($this->gitDir.'/description');
353+
}
354+
341355
/**
342356
* This command is a facility command. You can run any command
343357
* directly on git repository.

tests/Gitonomy/Git/Tests/RepositoryTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ public function testIsBare()
4646
$this->assertFalse($notBare->isBare(), "Working copy is not bare");
4747
}
4848

49+
/**
50+
* @dataProvider provideFoobar
51+
*/
52+
public function testGetDescription($repository)
53+
{
54+
$this->assertSame("Unnamed repository; edit this file 'description' to name the repository.\n", $repository->getDescription());
55+
}
56+
4957
/**
5058
* @dataProvider provideFoobar
5159
*/

0 commit comments

Comments
 (0)