Skip to content

Added documentation for GitData API #613

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions doc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ v3 APIs:
* [Enterprise](enterprise.md)
* [Gists](gists.md)
* [Comments](gists/comments.md)
* GitData
* [Blobs](gitdata/blobs.md)
* [Commits](gitdata/commits.md)
* [References](gitdata/references.md)
* [Tags](gitdata/tags.md)
* [Trees](gitdata/trees.md)
* [GraphQL](graphql.md)
* [Issues](issues.md)
* [Assignees](issue/assignees.md)
Expand Down
14 changes: 14 additions & 0 deletions doc/gitdata/blobs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
## Blobs API
[Back to the navigation](../README.md)

### Show a blob

```php
$blob = $client->api('gitData')->blobs()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
```

### Create a blob

```php
$blob = $client->api('gitData')->blobs()->create('KnpLabs', 'php-github-api', ['content' => 'Test content', 'encoding' => 'utf-8']);
```
15 changes: 15 additions & 0 deletions doc/gitdata/commits.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## Commits API
[Back to the navigation](../README.md)

### Show a commit

```php
$commit = $client->api('gitData')->commits()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
```

### Create a commit

```php
$commitData = ['message' => 'Upgrading documentation', 'tree' => $treeSHA, 'parents' => [$parentCommitSHA]];
$commit = $client->api('gitData')->commits()->create('KnpLabs', 'php-github-api', $commitData);
```
44 changes: 44 additions & 0 deletions doc/gitdata/references.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
## References API
[Back to the navigation](../README.md)


### List all references
```php
$references = $client->api('gitData')->references()->all('KnpLabs', 'php-github-api');
```

### Show a reference

```php
$reference = $client->api('gitData')->references()->show('KnpLabs', 'php-github-api', 'heads/featureA');
```

### Create a reference

```php
$referenceData = ['ref' => 'refs/heads/featureA', 'sha' => '839e5185da9434753db47959bee16642bb4f2ce4'];
$reference = $client->api('gitData')->references()->create('KnpLabs', 'php-github-api', $referenceData);
```

### Update a reference

```php
$referenceData = ['sha' => '839e5185da9434753db47959bee16642bb4f2ce4', 'force' => false ]; //Force is default false
$reference = $client->api('gitData')->references()->update('KnpLabs', 'php-github-api', 'heads/featureA', $referenceData);
```

### Delete a reference

```php
$client->api('gitData')->references()->remove('KnpLabs', 'php-github-api', 'heads/featureA');
```

### List all branches
```php
$references = $client->api('gitData')->references()->branches('KnpLabs', 'php-github-api');
```

### List all tags
```php
$references = $client->api('gitData')->references()->tags('KnpLabs', 'php-github-api');
```
32 changes: 32 additions & 0 deletions doc/gitdata/tags.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
## Tags API
[Back to the navigation](../README.md)

### Show all tags

```php
$tags = $client->api('gitData')->tags()->all('KnpLabs', 'php-github-api');
```

### Show a tag

```php
$tag = $client->api('gitData')->tags()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
```

### Create a tag

```php
$tagData = [
'tag' => 'v0.0.1',
'message' => 'initial version',
'object' => 'c3d0be41ecbe669545ee3e94d31ed9a4bc91ee3c',
'type' => 'commit',
'tagger' => [
'name' => 'KnpLabs',
'email' => 'hello@knplabs.com',
'date' => '2017-06-17T14:53:35-07:00'
]
];

$tag = $client->api('gitData')->tags()->create('KnpLabs', 'php-github-api', $tagData);
```
25 changes: 25 additions & 0 deletions doc/gitdata/trees.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
## Trees API
[Back to the navigation](../README.md)

### Show a tree

```php
$tree = $client->api('gitData')->trees()->show('KnpLabs', 'php-github-api', '839e5185da9434753db47959bee16642bb4f2ce4');
```

### Create a tree

```php
$treeData = [
'base_tree' => '839e5185da9434753db47959bee16642bb4f2ce4',
'tree' => [
[
'path' => 'README.md',
'mode' => '100644',
'type' => 'blob',
'content' => 'Updated Readme file'
]
]
];
$tree = $client->api('gitData')->trees()->create('KnpLabs', 'php-github-api', $treeData);
```