嗨,我正在使用GitHub v3,我想在 repo 中添加新的二进制文件。通过使用KnpLabs php-github-api我完全按照中所说的去做
- 获取当前提交对象
- 检索它指向的树
- 检索该特定文件路径的树具有的 blob 对象的内容
- 以某种方式更改内容并使用该新内容发布一个新的 blob 对象,返回一个 blob SHA
- 发布一个新的树对象,该文件路径指针替换为您的新 blob SHA 获取树 SHA
等等。但是在 5 点上我得到了一个例外
server error
形成这个代码
$comit=$client->api('git')->commits()->show($userName,$reposit,'master');
$basetree=$client->api('git')->trees()->show($userName,'appwiz',$comit['commit'] ['tree']['sha']);
$newBlob=$client->api('git')->blobs()->create($userName,$reposit,array('content'=> "gitapi",'encoding'=>'base64'));
$client->authenticate($userName,$password,Github\Client::AUTH_HTTP_PASSWORD);
$treeData = array(
'tree'=>
array( array('path'=>'/'
,'mode'=>'040000'
,'type'=>'tree'
,'content'=>'folder')
)
);