-
-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a0bea92
commit 4849e9f
Showing
35 changed files
with
1,091 additions
and
1,052 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
Create and access git repositories | ||
================================== | ||
|
||
gitlib provides methods to initialize new repositories. | ||
|
||
Create a repository | ||
------------------- | ||
|
||
To initialize a new repository, use method `Admin::init`. | ||
|
||
```php | ||
// Initialize a bare repository | ||
$repository = Gitonomy\Git\Admin::init('/path/to/repository'); | ||
|
||
// Initialize a non-bare repository | ||
$repository = Gitonomy\Git\Admin::init('/path/to/repository', false); | ||
``` | ||
|
||
Default behavior is to create a bare repository. If you want to | ||
initialize a repository with a working copy,pass `false` as third | ||
argument of Repository constructor. | ||
|
||
Cloning repositories | ||
-------------------- | ||
|
||
You can clone a repository from an URL by doing: | ||
|
||
```php | ||
// Clone to a bare repository | ||
$repository = Gitonomy\Git\Admin::cloneTo('/tmp/gitlib', 'https://github.com/gitonomy/gitlib.git'); | ||
|
||
// Clone to a non-bare repository | ||
$repository = Gitonomy\Git\Admin::cloneTo('/tmp/gitlib', 'https://github.com/gitonomy/gitlib.git', false); | ||
``` | ||
|
||
Default behavior is to clone in a bare repository. | ||
|
||
You can also clone a repository and point it to a specific branch. In a | ||
non-bare repository, this branch will be checked out: | ||
|
||
```php | ||
// Clone to a bare repository | ||
$repository = Gitonomy\Git\Admin::cloneBranchTo('/tmp/gitlib', 'https://github.com/gitonomy/gitlib.git', 'a-branch'); | ||
|
||
// Clone to a non-bare repository | ||
$repository = Gitonomy\Git\Admin::cloneBranchTo('/tmp/gitlib', 'https://github.com/gitonomy/gitlib.git', 'a-branch' false); | ||
``` | ||
|
||
Clone a Repository object | ||
------------------------- | ||
|
||
If you already have a Repository instance and want to clone it, you can | ||
use this shortcut: | ||
|
||
```php | ||
$new = $repository->cloneTo('/tmp/clone'); | ||
``` | ||
|
||
Mirror a repository | ||
------------------- | ||
|
||
If you want to mirror fully a repository and all references, use the | ||
`mirrorTo` method. This method takes only two arguments, where to mirror | ||
and what to mirror: | ||
|
||
```php | ||
// Mirror to a bare repository | ||
$mirror = Gitonomy\Git\Admin::mirrorTo('/tmp/mirror', 'https://github.com/gitonomy/gitlib.git'); | ||
|
||
// Mirror to a non-bare repository | ||
$mirror = Gitonomy\Git\Admin::mirrorTo('/tmp/mirror', 'https://github.com/gitonomy/gitlib.git', false); | ||
``` | ||
|
||
### References | ||
|
||
- <http://linux.die.net/man/1/git-init> | ||
- <http://linux.die.net/man/1/git-clone> |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
Blaming files | ||
============= | ||
|
||
Line-per-line iteration | ||
----------------------- | ||
|
||
To iterate on lines of a blame: | ||
|
||
```php | ||
$blame = $repository->getBlame('master', 'README.md'); | ||
|
||
foreach ($blame->getLines() as $lineNumber => $line) { | ||
$commit = $line->getCommit(); | ||
echo $lineNumber.': '.$line->getContent()." - ".$commit->getAuthorName()."\n"; | ||
} | ||
``` | ||
|
||
The *getLines* method returns an array indexed starting from 1. | ||
|
||
As you can see, you can access the commit object related to the line you | ||
are iterating on. | ||
|
||
If you want to access directly a line: | ||
|
||
```php | ||
$line = $blame->getLine(32); | ||
``` | ||
|
||
The Line object | ||
--------------- | ||
|
||
LineObject represents an item of the blame file. It is composed of those | ||
informations: | ||
|
||
```php | ||
$line->getCommit(); // returns a Commit | ||
$line->getContent(); // returns text | ||
|
||
// you can access author from commmit: | ||
$author = $line->getCommit()->getAuthorName(); | ||
``` | ||
|
||
Group reading by commit | ||
----------------------- | ||
|
||
If you plan to display it, you'll probably need a version where lines | ||
from same commit are grouped. | ||
|
||
To do so, use the *getGroupedLines* method that will return an array | ||
like this: | ||
|
||
```php | ||
$blame = array( | ||
array(Commit, array(1 => Line, 2 => Line, 3 => Line)), | ||
array(Commit, array(4 => Line)), | ||
array(Commit, array(5 => Line, 6 => Line)) | ||
) | ||
``` |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.