Add more classes to php-libgit
This commit is contained in:
parent
9d54e18b1f
commit
e5591fa56f
|
@ -25,7 +25,10 @@ function sha1_from_bin($bin)
|
||||||
|
|
||||||
require(dirname(__FILE__) . "/class.repository.php");
|
require(dirname(__FILE__) . "/class.repository.php");
|
||||||
require(dirname(__FILE__) . "/class.object.php");
|
require(dirname(__FILE__) . "/class.object.php");
|
||||||
|
require(dirname(__FILE__) . "/class.blob.php");
|
||||||
|
require(dirname(__FILE__) . "/class.tag.php");
|
||||||
require(dirname(__FILE__) . "/class.tree.php");
|
require(dirname(__FILE__) . "/class.tree.php");
|
||||||
|
require(dirname(__FILE__) . "/class.tree.element.php");
|
||||||
require(dirname(__FILE__) . "/class.commit.php");
|
require(dirname(__FILE__) . "/class.commit.php");
|
||||||
require(dirname(__FILE__) . "/class.actor.php");
|
require(dirname(__FILE__) . "/class.actor.php");
|
||||||
?>
|
?>
|
||||||
|
|
8
public_html/libgit/class.blob.php
Normal file
8
public_html/libgit/class.blob.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
class GitBlob extends GitObject
|
||||||
|
{
|
||||||
|
function __construct($repo, $headerdata, $data)
|
||||||
|
{
|
||||||
|
parent::__construct($repo, $headerdata, $data);
|
||||||
|
}
|
||||||
|
}
|
8
public_html/libgit/class.tag.php
Normal file
8
public_html/libgit/class.tag.php
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
<?php
|
||||||
|
class GitTag extends GitObject
|
||||||
|
{
|
||||||
|
function __construct($repo, $headerdata, $data)
|
||||||
|
{
|
||||||
|
parent::__construct($repo, $headerdata, $data);
|
||||||
|
}
|
||||||
|
}
|
14
public_html/libgit/class.tree.element.php
Normal file
14
public_html/libgit/class.tree.element.php
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?php
|
||||||
|
class GitTreeElement
|
||||||
|
{
|
||||||
|
public $mode = "";
|
||||||
|
public $filename = "";
|
||||||
|
public $hash = "";
|
||||||
|
|
||||||
|
function __construct($mode, $filename, $hash)
|
||||||
|
{
|
||||||
|
$this->mode = $mode;
|
||||||
|
$this->filename = $filename;
|
||||||
|
$this->hash = $hash;
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,5 +1,50 @@
|
||||||
<?php
|
<?php
|
||||||
class GitTree extends GitObject
|
class GitTree extends GitObject
|
||||||
{
|
{
|
||||||
|
public $elements = array();
|
||||||
|
|
||||||
|
function __construct($repo, $headerdata, $data)
|
||||||
|
{
|
||||||
|
parent::__construct($repo, $headerdata, $data);
|
||||||
|
|
||||||
|
$parsing_sha = false;
|
||||||
|
$sha_bytecount = 0;
|
||||||
|
$lines = array();
|
||||||
|
$current_line = "";
|
||||||
|
|
||||||
|
for($i = 0; $i < strlen($data); $i++)
|
||||||
|
{
|
||||||
|
$char = $data[$i];
|
||||||
|
$current_line .= $char;
|
||||||
|
|
||||||
|
if(ord($char) == 0)
|
||||||
|
{
|
||||||
|
$parsing_sha = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if($parsing_sha === true)
|
||||||
|
{
|
||||||
|
$sha_bytecount += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if($sha_bytecount == 20)
|
||||||
|
{
|
||||||
|
$parsing_sha = false;
|
||||||
|
$lines[] = $current_line;
|
||||||
|
$current_line = "";
|
||||||
|
$sha_bytecount = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$lines[] = $current_line;
|
||||||
|
|
||||||
|
foreach($lines as $line)
|
||||||
|
{
|
||||||
|
list($metadata, $binhash) = explode("\0", $line, 2);
|
||||||
|
list($mode, $filename) = explode(" ", $metadata, 2);
|
||||||
|
$hash = sha1_from_bin($binhash);
|
||||||
|
$this->elements[] = new GitTreeElement($mode, $filename, $hash);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
public_html/test.hex
Normal file
BIN
public_html/test.hex
Normal file
Binary file not shown.
|
@ -2,7 +2,8 @@
|
||||||
require("libgit/base.php");
|
require("libgit/base.php");
|
||||||
|
|
||||||
$s = new GitRepository("/home/occupy/testrepo.git");
|
$s = new GitRepository("/home/occupy/testrepo.git");
|
||||||
pretty_dump($s->GetObject("54e03e490b1bee1c154c3545bf258cab0629ee02"));
|
/*pretty_dump($s->GetObject("54e03e490b1bee1c154c3545bf258cab0629ee02"));
|
||||||
pretty_dump($s->GetObject("98d99489382a3541e6783bb2083554785f3eb72a"));
|
pretty_dump($s->GetObject("98d99489382a3541e6783bb2083554785f3eb72a"));
|
||||||
pretty_dump($s->GetObject("9d8e0ba4a30f6a5d775a879c42c7de5aed4530c6"));
|
pretty_dump($s->GetObject("9d8e0ba4a30f6a5d775a879c42c7de5aed4530c6"));
|
||||||
pretty_dump($s->GetObject("710bfee4440517255475bf7c5454c0bdbb3b3e56"));
|
pretty_dump($s->GetObject("710bfee4440517255475bf7c5454c0bdbb3b3e56"));*/
|
||||||
|
pretty_dump($s->GetObject("dba13ed2ddf783ee8118c6a581dbf75305f816a3"));
|
||||||
|
|
Loading…
Reference in a new issue