Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class UpdateMaker
- {
- public $path = null;
- public $startTag = null;
- public $endTag = null;
- public $result = array();
- public function __construct($options)
- {
- $this->path = $options['path'];
- $this->startTag = $options['startTag'];
- $this->endTag = $options['endTag'];
- $this->getModiedFiles();
- }
- public function getModiedFiles()
- {
- $path = $this->path;
- $startTag = $this->startTag;
- $endTag = $this->endTag;
- $oneLineCommand = "cd $path && git diff $startTag $endTag --name-only";
- exec($oneLineCommand, $this->result);
- }
- public function save($path)
- {
- foreach ($this->result as $key => $value)
- {
- $fullPath = $this->path.$value;
- if (file_exists($fullPath))
- $this->result[$key] = $fullPath;
- else
- unset($this->result[$key]);
- }
- $files = '"'.implode('" "', $this->result).'"';
- $result = array();
- exec("/bin/tar -cf $path $files", $result);
- }
- }
- $updater = new UpdateMaker(array(
- 'path'=>'/var/www/ImageCMS/',
- 'startTag'=>'v2.1.6',
- 'endTag'=>'v2.5.5',
- ));
- $updater->save('/home/username/result.tar');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement