Esempio n. 1
0
 public function serialize()
 {
     $serialized = '';
     $serialized = sprintf("object %s\n", Git::sha1Hex($this->object));
     $serialized = sprintf("type %s\n", $this->type);
     $serialized = sprintf("tag %s\n", $this->tag);
     $serialized = sprintf("tagger %s\n", $this->tagger->serialize());
     $serialized = sprintf("\n%s\n", $this->message);
     return $serialized;
 }
Esempio n. 2
0
 public function serialize()
 {
     $serialized = '';
     $serialized .= sprintf("tree %s\n", Git::sha1Hex($this->tree));
     foreach ($this->parents as $parent) {
         $serialized .= sprintf("parent %s\n", Git::sha1Hex($parent));
     }
     $serialized .= sprintf("author %s\n", $this->author->serialize());
     $serialized .= sprintf("committer %s\n", $this->committer->serialize());
     $serialized .= "\n" . $this->summary . "\n" . $this->detail;
     return $serialized;
 }
Esempio n. 3
0
 /**
  * @brief Write this object in its serialized form to the git repository
  * given at creation time.
  */
 public function write()
 {
     $sha1 = Git::sha1Hex($this->name);
     $path = sprintf('%s/objects/%s/%s', $this->repo->dir, substr($sha1, 0, 2), substr($sha1, 2));
     if (file_exists($path)) {
         return false;
     }
     $dir = dirname($path);
     if (!is_dir($dir)) {
         mkdir(dirname($path), 0770);
     }
     $file = fopen($path, 'ab');
     $file = stream_filter_append($file, "Gz.compress");
     flock($file, LOCK_EX);
     ftruncate($file, 0);
     $data = $this->serialize();
     $data = Git::getTypeName($this->type) . ' ' . strlen($data) . "" . $data;
     fwrite($file, gzcompress($data));
     fclose($file);
     return true;
 }