sebwite/git

Github/Bitbucket api with equal interface and flysystem.

1.0.0 2016-06-22 01:35 UTC

This package is auto-updated.

Last update: 2024-10-17 09:54:40 UTC


README

Build Status Scrutinizer coverage Scrutinizer quality Source License

The sebwite/git package provides seemless switching between github and bitbucket API calls and filesystem operations. Created for the Laravel 5 framework.

The package follows the FIG standards PSR-1, PSR-2, and PSR-4 to ensure a high level of interoperability between shared PHP code.

Quick Overview

For the full documenation, check out the sebwite-git package documenatation.

Configuration

Define your connections in config/services.php.

return [
    'conn1' => [
        'driver'    => 'bitbucket', // bitbucket | github
        'auth'      => Sebwite\Git\Manager::AUTH_BASIC,
        'username'  => 'user1',
        'password'  => 'passwd'                
    ],
    'conn2' => [
        'driver'    => 'bitbucket', // bitbucket | github
        'auth'      => Sebwite\Git\Manager::AUTH_OAUTH,
        'key'       => 'a#W23r2baaaf',
        'secret'    => 'we8r9w1ef32f'                
    ],
    'conn3' => [
        'driver'    => 'github', // bitbucket | github
        'auth'      => Sebwite\Git\Manager::AUTH_TOKEN,
        'secret'    => 'asAER4562aw32po'       
    ]
];    

Filesystem

$fs = Git::getFilesystem($repo, $owner = null, $ref = null);
$fs->exists('composer.json');
$com = $fs->get('composer.json');
// the other Flysystem methods yo are most likely familiar with..

API calls

Git::getUser();
Git::getUsername();
Git::listWebhooks($repo, $owner = null);
Git::getWebhook($repo, $uuid, $owner = null);
Git::createWebhook($repo, array $data, $owner = null);
Git::removeWebhook($repo, $uuid, $owner = null);
Git::listOrganisations($owner = null);
Git::listRepositories($owner = null);
Git::createRepository($repo, array $data = [ ], $owner = null);
Git::deleteRepository($repo, $owner = null);
Git::getBranches($repo, $owner = null);
Git::getMainBranch($repo, $owner = null);
Git::getRepositoryManifest($repo, $ref, $owner = null);
Git::getTags($repo, $owner = null);
Git::getRaw($repo, $ref, $path, $owner = null);
Git::getChangeset($repo, $ref, $path, $owner = null);
Git::getRepositoryCommits($repo, $owner = null);
Git::getBranchCommits($repo, $branch, $owner = null);

Transformers

Transformers are responsible for transforming the raw api call response data into a common, similar response. If wanted, you can extend and use your own implementation. Also provided is a NullTransformer which won't transform anything.

Git::setTransformer(NullTransformer::class);
Git::setTransformer(BitbucketTransformer::class);
Git::setTransformer(GithubTransformer::class);