Skip to content

Commit 792dfaa

Browse files
author
alexandresalome
committed
add tests and documentation for clone feature
1 parent a75ce5e commit 792dfaa

File tree

5 files changed

+75
-3
lines changed

5 files changed

+75
-3
lines changed

doc/api/admin.rst

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,27 @@ second argument:
2121

2222
.. code-block:: php
2323
24-
$repository = Gitonomy\Git\Admin::init('/path/to/folder', false);
24+
$repository = Gitonomy\Git\Admin::init('/tmp/git_sandbox', false);
25+
26+
Cloning repositories
27+
::::::::::::::::::::
28+
29+
You can clone a repository from an URL by doing:
30+
31+
.. code-block:: php
32+
33+
$repository = Gitonomy\Git\Admin::cloneTo('/tmp/gitlib', 'https://github.com/gitonomy/gitlib.git');
34+
35+
You can pass ``false`` and third argument to get a repository with a working copy.
36+
37+
If you already have a Repository instance and want to clone it, you can use this shortcut:
38+
39+
.. code-block:: php
40+
41+
$new = $repository->cloneTo('/tmp/clone');
2542
2643
References
2744
::::::::::
2845

29-
- http://linux.die.net/man/1/git-init
46+
* http://linux.die.net/man/1/git-init
47+
* http://linux.die.net/man/1/git-clone

doc/development.rst

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Developing gitlib
2+
=================
3+
4+
If you plan to contribute to gitlib, here are few things you should know:
5+
6+
Documentation generation
7+
::::::::::::::::::::::::
8+
9+
Documentation is generated using Sphinx (restructured text). Configuration file
10+
is located in https://github.com/gitonomy/website/blob/master/bin/conf.py
11+
12+
You will need to fetch vendor modules for PHP blocks especially. If you really
13+
want to generate it, install the website project locally and hack into it.

doc/index.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ Missing features
3333
Some major features are still missing from gitlib:
3434

3535
* Remotes
36-
* Clone
3736
* Submodules
3837

3938
If you want to run git commands on repository, call method ``Repository::run`` with method and arguments.

doc/installation.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Installation of gitlib
2+
======================
3+
4+
Autoloading
5+
:::::::::::
6+
7+
gitlib relies on class autoloading. It does not require any additional setup.
8+
9+
Using composer
10+
::::::::::::::
11+
12+
Edit your ``composer.json`` file and add ``gitonomy/gitlib`` in section ``require``:
13+
14+
.. code-block:: json
15+
16+
{
17+
"require": {
18+
"gitonomy/gitlib": "dev-master"
19+
}
20+
}

tests/Gitonomy/Git/Tests/AdminTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,28 @@ public function testNotBare()
5555
$this->assertEquals($this->tmpDir, $repository->getWorkingDir(), "working dir present in bare repository");
5656
}
5757

58+
/**
59+
* @dataProvider provideFoobar
60+
*/
61+
public function testClone($repository)
62+
{
63+
$newDir = self::createTempDir();
64+
$new = $repository->cloneTo($newDir, $repository->isBare());
65+
self::registerDeletion($new);
66+
67+
$oldRefs = $repository->getReferences()->getAll();
68+
$newRefs = $new->getReferences()->getAll();
69+
70+
$this->assertEquals(array_keys($oldRefs), array_keys($newRefs), "same references in both repositories");
71+
72+
if ($repository->isBare()) {
73+
$this->assertEquals($newDir, $new->getGitDir());
74+
} else {
75+
$this->assertEquals($newDir.'/.git', $new->getGitDir());
76+
$this->assertEquals($newDir, $new->getWorkingDir());
77+
}
78+
}
79+
5880
/**
5981
* @expectedException RuntimeException
6082
*/

0 commit comments

Comments
 (0)