libgit2 / php-git

PHP bindings for libgit2
http://libgit2.github.com
MIT License
563 stars 118 forks source link

How can I commit automatically ? #47

Open Supradyn opened 11 years ago

Supradyn commented 11 years ago

Hi! I need to commit all files in work_dir like "git commit -a". I can't get it from docs. And in readme.md its like:

$bld = new Git2\TreeBuilder();
$bld->insert(new Git2\TreeEntry(array(
    "name" => "README.txt",
    "oid" => "63542fbea05732b78711479a31557bd1b0aa2116",
    "attributes" => octdec('100644'),
)));
$tree = $bld->write($repo);

How can I get this oid ? It doesnt work like $repo->hash("file-path")

raiviskrumins commented 10 years ago

+1

chobie commented 10 years ago

sorry for late response.

please check this block. probably I didn't add filename base api so you have to read contents by hand and put it into write api. https://github.com/chobie/kokuban/blob/master/Kokuban/GistProvider.php#L34

Currently, php-git doesn't defined GIT_OBJ_BLOB constant. so please define it in user land. https://github.com/libgit2/libgit2/blob/d18713fb4ad1ba3d18a75272e1c1c3eb45715aba/include/git2/types.h#L73

Also, php-git uses old version of libgit2. I want to update libgit2 version foreseeable future but I have many php-extensions to maintain. so maybe It takes log time to upgrade.