shadiakiki1986/git-rest-api-client

A php client interfacing with the rest api from node-git-rest-api

0.0.14 2017-01-16 11:32 UTC

This package is auto-updated.

Last update: 2024-10-27 03:36:50 UTC


README

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:PASSWORD@github.com/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:veggiepizza@github.com/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:mypassword@bitbucket.org/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