PHP client interfacing with RESTful API from server running node-git-rest-api, as dockerized in docker-node-git-rest-api
Published on packagist
composer require shadiakiki1986/git-rest-api-client
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');
'
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
Check git-data-repo
2016-11-19
- push is not pushing to github
- travis not passing