shadiakiki1986/git-rest-api-client

一个 PHP 客户端,用于与 node-git-rest-api 的 RESTful API 进行交互

0.0.14 2017-01-16 11:32 UTC

This package is auto-updated.

Last update: 2024-09-27 03:19:36 UTC


README

Build Status

PHP 客户端,与运行在 node-git-rest-api 服务器上的 RESTful API 进行交互,该服务器已在 docker-node-git-rest-api 中进行 Docker 化

安装

packagist 上发布

composer require shadiakiki1986/git-rest-api-client

使用

启动 node-git-rest-api 服务器

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

要更改仓库中的文件

$git        = new GitRestApi\Client('https://: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();

要拉取更改并获取文件内容

$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');

本地测试

非常重要:请不要在本地机器上直接运行 node-git-rest-api 并测试此包。测试中包含了一些 git config --global ... 调用,这会更改您本地机器上的用户名/电子邮件地址,从而破坏您在其他所有仓库中的 git 提交。

启动 node-git-rest-api 服务器

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

composer test 将测试一切,除了成功的推送。

export GitRestApiTestUrl=https://shadiakiki1986:veggiepizza@github.com/shadiakiki1986/git-data-repo-testDataRepo
composer test

将测试一切,包括成功的推送。

针对我的自建 bitbucket 私有仓库进行测试

PRIVATE_REMOTE=https://myusername:mypassword@bitbucket.org/shadiakiki1986/ffa-bdlreports-maps/ PRIVATE_FILE=filename vendor/bin/phpunit tests/GitRestApi/PrivateTest.php

在 travis 上进行测试

检查 git-data-repo

待办事项

2016-11-19

  • 推送没有推送到 GitHub
  • travis 没有通过