mirror of
				https://github.com/hauke68/Magallanes.git
				synced 2025-11-04 09:00:18 +01:00 
			
		
		
		
	Added the possibility defining (by the user) Excludes for the
rsync.
This commit is contained in:
		
							parent
							
								
									c5ce864371
								
							
						
					
					
						commit
						8ed0154749
					
				@ -16,6 +16,7 @@ class Mage_Task_Add
 | 
				
			|||||||
                        . 'user: dummy' . PHP_EOL
 | 
					                        . 'user: dummy' . PHP_EOL
 | 
				
			||||||
                        . 'deploy-from: ./' . PHP_EOL
 | 
					                        . 'deploy-from: ./' . PHP_EOL
 | 
				
			||||||
                        . 'deploy-to: /var/www/vhosts/example.com/www' . PHP_EOL
 | 
					                        . 'deploy-to: /var/www/vhosts/example.com/www' . PHP_EOL
 | 
				
			||||||
 | 
					                        . 'rsync-excludes:' . PHP_EOL
 | 
				
			||||||
                        . 'hosts:' . PHP_EOL
 | 
					                        . 'hosts:' . PHP_EOL
 | 
				
			||||||
                        . 'pre-tasks:' . PHP_EOL
 | 
					                        . 'pre-tasks:' . PHP_EOL
 | 
				
			||||||
                        . 'tasks:' . PHP_EOL
 | 
					                        . 'tasks:' . PHP_EOL
 | 
				
			||||||
 | 
				
			|||||||
@ -9,15 +9,22 @@ class Mage_Task_BuiltIn_Deployment_Rsync
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    public function run()
 | 
					    public function run()
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
        $ignores = array(
 | 
					        $excludes = array(
 | 
				
			||||||
            '--exclude .git',
 | 
					            '.git',
 | 
				
			||||||
            '--exclude .svn',
 | 
					            '.svn',
 | 
				
			||||||
            '--exclude .mage',
 | 
					            '.mage',
 | 
				
			||||||
            '--exclude .gitignore'
 | 
					            '.gitignore'
 | 
				
			||||||
        );
 | 
					        );
 | 
				
			||||||
        
 | 
					        
 | 
				
			||||||
 | 
					        // Look for User Excludes
 | 
				
			||||||
 | 
					        if (isset($this->_config['deploy']['rsync-excludes'])) {
 | 
				
			||||||
 | 
					            $userExcludes = (array) $this->_config['deploy']['rsync-excludes'];
 | 
				
			||||||
 | 
					        } else {
 | 
				
			||||||
 | 
					            $userExcludes = array();
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        $command = 'rsync -avz '
 | 
					        $command = 'rsync -avz '
 | 
				
			||||||
                 . implode(' ', $ignores) .' '
 | 
					                 . $this->_excludes($excludes + $userExcludes) . ' '
 | 
				
			||||||
                 . $this->_config['deploy']['deploy-from'] . ' '
 | 
					                 . $this->_config['deploy']['deploy-from'] . ' '
 | 
				
			||||||
                 . $this->_config['deploy']['user'] . '@' . $this->_config['deploy']['host'] . ':' . $this->_config['deploy']['deploy-to'];
 | 
					                 . $this->_config['deploy']['user'] . '@' . $this->_config['deploy']['host'] . ':' . $this->_config['deploy']['deploy-to'];
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@ -25,4 +32,15 @@ class Mage_Task_BuiltIn_Deployment_Rsync
 | 
				
			|||||||
        
 | 
					        
 | 
				
			||||||
        return $result;
 | 
					        return $result;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					    
 | 
				
			||||||
 | 
					    private function _excludes(Array $excludes)
 | 
				
			||||||
 | 
					    {
 | 
				
			||||||
 | 
					        $excludesRsync = '';
 | 
				
			||||||
 | 
					        foreach ($excludes as $exclude) {
 | 
				
			||||||
 | 
					            $excludesRsync .= ' --exclude ' . $exclude . ' ';
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
 | 
					        
 | 
				
			||||||
 | 
					        $excludesRsync = trim($excludesRsync);
 | 
				
			||||||
 | 
					        return $excludesRsync;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
		Loading…
	
		Reference in New Issue
	
	Block a user