Browse Source

Add branch

master
Sven Slootweg 10 years ago
parent
commit
3801d0904f
  1. 1
      public_html/libgit/base.php
  2. 5
      public_html/libgit/class.repository.php
  3. 49
      public_html/libgit/class.tag.php
  4. 3
      public_html/test.php

1
public_html/libgit/base.php

@ -24,6 +24,7 @@ function sha1_from_bin($bin)
}
require(dirname(__FILE__) . "/class.repository.php");
require(dirname(__FILE__) . "/class.branch.php");
require(dirname(__FILE__) . "/class.object.php");
require(dirname(__FILE__) . "/class.blob.php");
require(dirname(__FILE__) . "/class.tag.php");

5
public_html/libgit/class.repository.php

@ -51,4 +51,9 @@ class GitRepository
break;
}
}
function GetBranch($name)
{
return new GitBranch($this, $sha);
}
}

49
public_html/libgit/class.tag.php

@ -1,8 +1,57 @@
<?php
class GitTag extends GitObject
{
public $target = "";
public $tagger = "";
public $type = "";
public $tag = "";
public $message = "";
function __construct($repo, $headerdata, $data)
{
parent::__construct($repo, $headerdata, $data);
$lines = explode("\n", $data);
$message_parts = array();
$parsing_message = false;
foreach($lines as $line)
{
$line = trim($line);
if(!empty($line))
{
if($parsing_message === false)
{
list($key, $value) = explode(" ", $line, 2);
switch($key)
{
case "object":
$this->target = $value;
break;
case "tagger":
$this->tagger = new GitActor($value);
break;
case "type":
$this->type = $value;
break;
case "tag":
$this->tag = $value;
break;
}
}
else
{
$message_parts[] = $line;
}
}
else
{
$parsing_message = true;
}
}
$this->message = implode("\n", $message_parts);
}
}

3
public_html/test.php

@ -6,4 +6,5 @@ $s = new GitRepository("/home/occupy/testrepo.git");
pretty_dump($s->GetObject("98d99489382a3541e6783bb2083554785f3eb72a"));
pretty_dump($s->GetObject("9d8e0ba4a30f6a5d775a879c42c7de5aed4530c6"));
pretty_dump($s->GetObject("710bfee4440517255475bf7c5454c0bdbb3b3e56"));*/
pretty_dump($s->GetObject("dba13ed2ddf783ee8118c6a581dbf75305f816a3"));
pretty_dump($s->GetObject("ab2d7159831970ca08f2c9fc5c0fa34b17d572e9"));
pretty_dump($s->GetObject("cdebafd9e7426d0243cfb0a4ea2116a8b97b01e7"));
Loading…
Cancel
Save