daily pastebin goal
82%
SHARE
TWEET

Untitled

a guest Sep 12th, 2011 122 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. class UpdateMaker
  4. {
  5.         public $path = null;
  6.         public $startTag = null;
  7.         public $endTag =  null;
  8.         public $result = array();
  9.  
  10.         public function __construct($options)
  11.         {
  12.                 $this->path = $options['path'];
  13.                 $this->startTag = $options['startTag'];
  14.                 $this->endTag = $options['endTag'];
  15.                 $this->getModiedFiles();
  16.         }
  17.  
  18.         public function getModiedFiles()
  19.         {
  20.                 $path = $this->path;
  21.                 $startTag = $this->startTag;
  22.                 $endTag = $this->endTag;
  23.                 $oneLineCommand = "cd $path && git diff $startTag $endTag --name-only";
  24.                 exec($oneLineCommand, $this->result);
  25.         }
  26.  
  27.         public function save($path)
  28.         {
  29.                 foreach ($this->result as $key => $value)
  30.                 {
  31.                         $fullPath = $this->path.$value;
  32.                         if (file_exists($fullPath))
  33.                                 $this->result[$key] = $fullPath;
  34.                         else
  35.                                 unset($this->result[$key]);
  36.                 }
  37.  
  38.                 $files =  '"'.implode('" "', $this->result).'"';
  39.                 $result = array();
  40.                 exec("/bin/tar -cf $path $files", $result);
  41.         }
  42. }
  43.  
  44. $updater = new UpdateMaker(array(
  45.         'path'=>'/var/www/ImageCMS/',
  46.         'startTag'=>'v2.1.6',
  47.         'endTag'=>'v2.5.5',
  48. ));
  49.  
  50. $updater->save('/home/username/result.tar');
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top