dmamontov / git4p
0.0.5
2021-12-27 11:56 UTC
Requires
- php: ^7.4
Requires (Dev)
- apigen/apigen: v4.1.1
- codacy/coverage: dev-master
- codeclimate/php-test-reporter: dev-master
- phpunit/phpunit: ^4.6
This package is auto-updated.
Last update: 2024-08-27 18:06:35 UTC
README
状态:已不再活跃 / 已存档
Git4P
"Git4P"代表"Git for PHP",是一个本机PHP Git库,可以在不使用标准git命令等外部帮助的情况下访问Git仓库。它主要用于服务器端(裸)仓库。
请告诉我您如何使用这个库。
示例
创建一个新的裸仓库
Git::init('/tmp/mytestrepo');
添加一个简单的blob
在这个示例中,blob是'孤立的',这意味着它无法通过任何提交访问。
$git = Git::init('/tmp/mytestrepo'); $readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n"; $blob = new GitBlob($git); $blob->setData($readme) ->store();
带有单个提交的完整基本仓库
我们程序性地创建一个blob(文件),一个指向它的tree(目录)和一个指向树的commit。最后,我们确保master
分支指向这个commit。
$git = Git::init('/tmp/mytestrepo'); $readme = "GIT4P\n=====\n\nThis is a simple test repo for git4p.\n"; $user = new GitUser(); $user->setName('Some User') ->setEmail('some.user@example.com') ->setTimestamp('1374058686') ->setOffset('+0200'); $blob = new GitBlob($git); $blob->setData($readme) ->store(); $arr = ['README.md' => $b]; $tree = new GitTree($git); $tree->setData($arr) ->store(); $commit = new GitCommit($git); $commit->setTree($tree->sha()) ->setMessage('Initial commit.') ->addAuthor($user) ->addCommiter($user) ->store(); $git->updateBranch('master', $commit->sha());
注意
这个库目前对pack支持有限。通过GitRef支持读取和列出packed refs,但尚未实现packed objects的支持。
一些待办事项
- 添加pack支持
- 添加适当的phpdoc注释