diff --git a/public_html/libgit/base.php b/public_html/libgit/base.php new file mode 100644 index 0000000..f2feecd --- /dev/null +++ b/public_html/libgit/base.php @@ -0,0 +1,6 @@ + diff --git a/public_html/libgit/class.actor.php b/public_html/libgit/class.actor.php new file mode 100644 index 0000000..9b11295 --- /dev/null +++ b/public_html/libgit/class.actor.php @@ -0,0 +1,25 @@ +name = implode(" ", $name_parts); + $timestamp = $parts[$parts_count - 2] . " " . $parts[$parts_count - 1]; + + date_default_timezone_set("GMT"); + $this->timestamp = strtotime($parts[$parts_count - 1], $parts[$parts_count - 2]); + } +} diff --git a/public_html/libgit/class.commit.php b/public_html/libgit/class.commit.php new file mode 100644 index 0000000..341b4e5 --- /dev/null +++ b/public_html/libgit/class.commit.php @@ -0,0 +1,59 @@ +tree = $value; + break; + case "parent": + $this->parents[] = $value; + break; + case "committer": + $this->committer = new GitActor($value); + break; + case "author": + $this->author = new GitActor($value); + break; + } + } + else + { + $message_parts[] = $line; + } + } + else + { + $parsing_message = true; + } + } + + $this->message = implode("\n", $message_parts); + } +} diff --git a/public_html/libgit/class.object.php b/public_html/libgit/class.object.php new file mode 100644 index 0000000..c77f33f --- /dev/null +++ b/public_html/libgit/class.object.php @@ -0,0 +1,12 @@ +size = (int)$headerdata; + $this->rawdata = $data; + } +} diff --git a/public_html/libgit/class.repository.php b/public_html/libgit/class.repository.php new file mode 100644 index 0000000..bb72f71 --- /dev/null +++ b/public_html/libgit/class.repository.php @@ -0,0 +1,74 @@ +path = $path; + } + + function GetObjectRaw($sha) + { + return gzuncompress( + file_get_contents( + sprintf("{$this->path}/objects/%s/%s", + substr($sha, 0, 2), + substr($sha, 2) + ))); + } + + function GetObject($sha) + { + list($header, $data) = explode("\0", $this->GetObjectRaw($sha), 2); + + if(strpos($header, " ") !== false) + { + list($type, $headerdata) = explode(" ", $header, 2); + } + else + { + $type = $header; + $headerdata = ""; + } + + switch($type) + { + case "commit": + return new GitCommit($headerdata, $data); + break; + case "blob": + return new GitBlob($headerdata, $data); + break; + case "tree": + return new GitTree($headerdata, $data); + break; + case "tag": + return new GitTag($headerdata, $data); + break; + default: + return new GitObject($headerdata, $data); + break; + } + } +} diff --git a/public_html/test.php b/public_html/test.php new file mode 100644 index 0000000..77d90c2 --- /dev/null +++ b/public_html/test.php @@ -0,0 +1,5 @@ +GetObject("54e03e490b1bee1c154c3545bf258cab0629ee02"));