function create($add_filename) { $filepath = WORK_DIR . '/' . $add_filename; $sha1 = sha1_file($filepath); $filesize = filesize($filepath); $filename = $this->filename($sha1); $index = new \Pgit\Lib\Index(); $index->add($add_filename, $sha1, $filesize); if (file_exists($filename)) { return $sha1; } $blob = gzcompress('blob ' . $filesize . ' 0/' . file_get_contents($filepath), 9); mkdir(dirname($filename), 0777, TRUE); file_put_contents($filename, $blob); }
public function run() { $this->error->repository_exists(); $file = new \Pgit\Lib\File(); $working_files = $file->working_files(); $index = new \Pgit\Lib\Index(); $index_files = $index->get(); foreach ($working_files as $index => $working_file) { $working_file = trim($working_file); if (isset($index_files[$working_file])) { $color = 'green'; $filetype = 'modified'; } else { $color = 'red'; $filetype = 'new file'; } echo \Pgit\Lib\Color::text($color, sprintf(" %s: %s\n", $filetype, $working_file)); } }