Skip to content

Commit 0668229

Browse files
committed
Added some doc
1 parent b413b0b commit 0668229

File tree

4 files changed

+57
-6
lines changed

4 files changed

+57
-6
lines changed

doc/api.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ API documentation
1111
api/commit
1212
api/blame
1313
api/blob
14+
api/branch
1415
api/tree
1516
api/log
1617
api/diff

doc/api/branch.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Branch
2+
======
3+
4+
To access a *Branch*, starting from a repository object:
5+
6+
.. code-block:: php
7+
8+
$repository = new Gitonomy\Git\Repository('/path/to/repository');
9+
$branch = $repository->getReferences()->getBranch('master');
10+
11+
You can check is the branch is a local or remote one:
12+
13+
.. code-block:: php
14+
15+
$branch->isLocal();
16+
$branch->isRemote();

doc/api/commit.rst

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,33 @@ To access the message, you can use the *getMessage* method:
9494
$commit->getMessage();
9595
9696
For your convenience, this library provides a shortcut method to keep only the
97-
first line or first 80 characters if the first line is too long:
97+
first line or first 50 characters if the first line is too long:
9898

9999
.. code-block:: php
100100
101101
$commit->getShortMessage();
102102
103+
You can customize it like this:
104+
105+
.. code-block:: php
106+
107+
$commit->getShortMessage(45, true, '.');
108+
109+
* The first parameter is the max length of the message.
110+
* The second parameter determine if the last word should be cut or preserved
111+
* The third parameter is the separator
112+
113+
There are also two other methods for your convenience:
114+
115+
.. code-block:: php
116+
117+
// The first line
118+
$commit->getSubjectMessage();
119+
120+
// The body (rest of the message)
121+
$commit->getBodyMessage();
122+
123+
103124
Diff of a commit
104125
----------------
105126

@@ -137,3 +158,12 @@ Here is a very straightforward example:
137158
echo" Author: ".$last->getAuthorName()."\n";
138159
echo" Date: ".$last->getAuthorDate()->format('d/m/Y')."\n";
139160
echo" Message: ".$last->getMessage();
161+
162+
Find every branches containing a commit
163+
---------------------------------------
164+
165+
.. code-block:: php
166+
167+
$branches = $commit->getIncludingBranches($includeLocalBranches, $includeRemoteBranches);
168+
$localBranches = $commit->getIncludingBranches(true, false);
169+
$remoteBranches = $commit->getIncludingBranches(false, true);

doc/api/references.rst

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,21 @@ If you want to access all branches or all tags:
2323

2424
.. code-block:: php
2525
26-
$branches = $repository->getBranches();
27-
$tags = $repository->getTags();
28-
$all = $repository->getAll();
26+
$branches = $repository->getBranches();
27+
$localBranches = $repository->getLocalBranches();
28+
$remoteBranches = $repository->getRemoteBranches();
29+
$tags = $repository->getTags();
30+
$all = $repository->getAll();
2931
3032
To get a given branch or tag, call *getBranch* or *getTag* on the
3133
*ReferenceBag*. Those methods return *Branch* and *Tag* objects:
3234

3335
.. code-block:: php
3436
35-
$master = $references->getBranch('master');
36-
$v0_1 = $references->getTag('0.1');
37+
$master = $references->getBranch('master');
38+
$feat123 = $references->getLocalBranch('feat123');
39+
$feat456 = $references->getRemoteBranch('origin/feat456');
40+
$v0_1 = $references->getTag('0.1');
3741
3842
If the reference cannot be resolved, a *ReferenceNotFoundException* will be
3943
thrown.

0 commit comments

Comments
 (0)