Skip to content

Commit 99ad5e6

Browse files
author
alexandresalome
committed
update doc and tests
1 parent 7f45c84 commit 99ad5e6

File tree

5 files changed

+56
-58
lines changed

5 files changed

+56
-58
lines changed

doc/api/admin.rst

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
1-
Create git repositories
2-
=======================
1+
Administration of git repositories
2+
==================================
33

4-
Initialize a repository
5-
-----------------------
4+
Initializing repositories
5+
:::::::::::::::::::::::::
66

7-
Bare repository
8-
:::::::::::::::
7+
Create a bare repository
8+
------------------------
99

1010
You can create a bare repository using ``Admin::init``:
1111

1212
.. code-block:: php
1313
14-
use Gitonomy\Git\Admin;
14+
$repository = Gitonomy\Git\Admin::init('/path/to/repository');
1515
16-
$repository = Admin::init('/path/to/repository');
17-
18-
Non-bare repository
19-
:::::::::::::::::::
16+
Create a repository with a working copy
17+
---------------------------------------
2018

2119
If you want to create a repository with a working directory, pass ``false`` as
2220
second argument:
2321

2422
.. code-block:: php
2523
2624
$repository = Gitonomy\Git\Admin::init('/path/to/folder', false);
25+
26+
References
27+
::::::::::
28+
29+
- http://linux.die.net/man/1/git-init

doc/api/blame.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ If you want to access directly a line:
2828
Group reading by commit
2929
-----------------------
3030

31-
If you plan to display it, you'll probably need a version where lines from same commit are merged.
31+
If you plan to display it, you'll probably need a version where lines from same commit are grouped.
3232

3333
To do so, use the *getGroupedLines* method that will return an array like this:
3434

doc/index.rst

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,39 @@
1-
gitlib - PHP-library to access git
1+
gitlib - library to manipulate git
22
==================================
33

4-
View on Github: https://github.com/gitonomy/gitlib
4+
gitlib requires PHP 5.3 and class autoloading (PSR-0) to work properly. Internally, it relies on ``git`` method calls
5+
to fetch informations from repository.
56

6-
This library is a PHP-library for browsing git repositories.
7-
8-
This library relies on ``git`` command.
7+
.. code-block:: php
98
10-
Example
11-
-------
9+
use Gitonomy\Git\Repository;
1210
13-
.. code-block:: php
11+
$repository = new Repository('/path/to/repository');
1412
15-
$repository = new Gitonomy\Git\Repository('/path/to/repository');
16-
$master = $repository->getReferences()->getBranch('master');
13+
foreach ($repository->getReferences()->getBranches() as $branch) {
14+
echo "- ".$branch->getName();
15+
}
1716
18-
$author = $master->getCommit()->getAuthorName();
17+
$repository->run('fetch', array('--all'));
1918
20-
echo "Last modification on master made by ".$author;
2119
2220
Documentation
2321
-------------
2422

2523
.. toctree::
2624
:maxdepth: 2
2725

26+
installation
2827
api
29-
30-
Features
31-
--------
32-
33-
* Create repositories
34-
* Manage hooks in repositories
28+
development
3529

3630
Missing features
3731
----------------
3832

39-
* Remote management
40-
* Clone
41-
42-
Requirements
43-
------------
33+
Some major features are still missing from gitlib:
4434

45-
**Minimum PHP version**: PHP 5.3.3
35+
* Remotes
36+
* Clone
37+
* Submodules
4638

47-
To use this library, you must have *git* installed and available in shell.
39+
If you want to run git commands on repository, call method ``Repository::run`` with method and arguments.

tests/Gitonomy/Git/Tests/AdminTest.php

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
namespace Gitonomy\Git\Tests;
1414

1515
use Gitonomy\Git\Admin;
16+
use Gitonomy\Git\Repository;
1617

1718
class AdminTest extends AbstractTest
1819
{
@@ -25,45 +26,39 @@ public function setUp()
2526

2627
public function tearDown()
2728
{
28-
$this->deleteDir($this->tmpDir);
29+
$this->deleteDir($this->createTempDir());
2930
}
3031

31-
public function testBare_WithInitialDirectory_Works()
32+
public function testBare()
3233
{
33-
Admin::init($this->tmpDir);
34+
$repository = Admin::init($this->tmpDir);
3435

3536
$objectDir = $this->tmpDir.'/objects';
36-
$this->assertTrue(is_dir($objectDir), "objects/ folder is present");
37-
}
3837

39-
public function testBare_WithoutInitialDirectory_StillWorks()
40-
{
41-
Admin::init($this->tmpDir.'/test');
42-
43-
$objectDir = $this->tmpDir.'/test/objects';
38+
$this->assertTrue($repository->isBare(), "Repository is bare");
4439
$this->assertTrue(is_dir($objectDir), "objects/ folder is present");
40+
$this->assertTrue($repository instanceof Repository, "Admin::init returns a repository");
41+
$this->assertEquals($this->tmpDir, $repository->getGitDir(), "The folder passed as argument is git dir");
42+
$this->assertNull($repository->getWorkingDir(), "No working dir in bare repository");
4543
}
4644

47-
public function testNotBare_WithInitialDirectory_Works()
45+
public function testNotBare()
4846
{
49-
Admin::init($this->tmpDir, false);
47+
$repository = Admin::init($this->tmpDir, false);
5048

5149
$objectDir = $this->tmpDir.'/.git/objects';
52-
$this->assertTrue(is_dir($objectDir), "objects/ folder is present");
53-
}
54-
55-
public function testNotBare_WithoutInitialDirectory_StillWorks()
56-
{
57-
Admin::init($this->tmpDir.'/test', false);
5850

59-
$objectDir = $this->tmpDir.'/test/.git/objects';
60-
$this->assertTrue(is_dir($objectDir), "objects/ folder is present");
51+
$this->assertFalse($repository->isBare(), "Repository is not bare");
52+
$this->assertTrue(is_dir($objectDir), "objects/ folder is present");
53+
$this->assertTrue($repository instanceof Repository, "Admin::init returns a repository");
54+
$this->assertEquals($this->tmpDir.'/.git', $repository->getGitDir(), "git dir as subfolder of argument");
55+
$this->assertEquals($this->tmpDir, $repository->getWorkingDir(), "working dir present in bare repository");
6156
}
6257

6358
/**
6459
* @expectedException RuntimeException
6560
*/
66-
public function testFail()
61+
public function testExistingFile()
6762
{
6863
$file = $this->tmpDir.'/test';
6964
touch($file);

tests/Gitonomy/Git/Tests/RepositoryTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,10 @@ public function testEventDispatcher_Error()
9898

9999
public function testLoggerOk()
100100
{
101+
if (!class_exists('Psr\Log\LoggerInterface')) {
102+
$this->markTestSkipped();
103+
}
104+
101105
$logger = $this->getMock('Psr\Log\LoggerInterface');
102106
$logger
103107
->expects($this->once())
@@ -119,6 +123,10 @@ public function testLoggerOk()
119123
*/
120124
public function testLoggerNOk()
121125
{
126+
if (!class_exists('Psr\Log\LoggerInterface')) {
127+
$this->markTestSkipped();
128+
}
129+
122130
$logger = $this->getMock('Psr\Log\LoggerInterface');
123131
$logger
124132
->expects($this->once())

0 commit comments

Comments
 (0)