Skip to content

shadiakiki1986/git-rest-api-client-php

Repository files navigation

git-rest-api-client-php

Build Status

PHP client interfacing with RESTful API from server running node-git-rest-api, as dockerized in docker-node-git-rest-api

Install

Published on packagist

composer require shadiakiki1986/git-rest-api-client

Use

Launch a node-git-rest-api server

docker run -p 8081:8081 -it shadiakiki1986/docker-node-git-rest-api

To make changes to a file in a repository

$git        = new GitRestApi\Client('http://localhost:8081');
// clone a git repository on github
$remote = 'https://USERNAME:[email protected]/shadiakiki1986/git-data-repo-testDataRepo';
$repo = $git->cloneRemote($remote);
// update a file called 'filename' in the repository
$repo->put('filename','some content');
// commit the changes
$repo->commit('a new commit message');
// push to the remote
$repo->push();

To pull changes and get contents of a file

$git        = new GitRestApi\Client();
// get already-cloned git repository
$repo = $git->get('git-data-repo-testDataRepo');
// pull changes
$repo->pull();
// get contents of file
$repo->get('filename');

Testing locally

' VERY IMPORTANT NOTE: Do NOT directly run node-git-rest-api on your local machine and test this package against it. The tests contain a few git config --global ... calls, which would change your username/email on your local machine, and hence screwing up your git commits in all other repositories. '

Launch a node-git-rest-api server

docker run -p 8081:8081 -it shadiakiki1986/docker-node-git-rest-api

composer test will test everything except a successful push.

export GitRestApiTestUrl=https://shadiakiki1986:[email protected]/shadiakiki1986/git-data-repo-testDataRepo
composer test

will test everything, including the successful push.

For testing against my own bitbucket private repo:

PRIVATE_REMOTE=https://myusername:[email protected]/shadiakiki1986/ffa-bdlreports-maps/ PRIVATE_FILE=filename vendor/bin/phpunit tests/GitRestApi/PrivateTest.php

Testing on travis

Check git-data-repo

TODO

2016-11-19

  • push is not pushing to github
  • travis not passing

About

PHP client for git-rest-api server

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages