diff --git a/src/Artistan/Workbench/Commands/InstallCommand.php b/src/Artistan/Workbench/Commands/InstallCommand.php index b2153db..c00651d 100644 --- a/src/Artistan/Workbench/Commands/InstallCommand.php +++ b/src/Artistan/Workbench/Commands/InstallCommand.php @@ -60,9 +60,12 @@ public function fire() if(isset($package['git'])){ $this->benchhelper->mkdir($name); $action = $this->benchhelper->getGit($name,$package); - if($this->option('upstream')){ - echo "upstream\n"; - $this->benchhelper->getUpstream($name,$package,$this->option('merge')); + if($this->option('remote')){ + echo "remotes\n"; + $this->benchhelper->fetchRemotes($name,$package['remotes']); + } + if($this->option('merge')){ + $this->benchhelper->mergeRemote($this->option('merge')); } if(!$this->option('skipBower')){ $this->benchhelper->bower($name); diff --git a/src/Artistan/Workbench/Helpers/BenchHelper.php b/src/Artistan/Workbench/Helpers/BenchHelper.php index cc5224e..41cb21f 100644 --- a/src/Artistan/Workbench/Helpers/BenchHelper.php +++ b/src/Artistan/Workbench/Helpers/BenchHelper.php @@ -127,41 +127,45 @@ public function getGit($name,array $package) { } } - public function getUpstream($name,array $package,$merge){ - echo "get git $name\n"; - if(!empty($package['git'])){ - if(!empty($package['upstream'])){ - //$this->call('command:name', array('argument' => 'foo', '--option' => 'bar')); - chdir(base_path().'/workbench/'.$name); - if(is_dir('.git')){ - if(!$this->verifyUpstream($name)){ - $this->exec('git remote add upstream '.$package['upstream']); - } - if($this->verifyUpstream($name)){ - $this->exec('git fetch upstream'); - if($merge){ - $this->exec('git merge upstream/'.$merge); - } else { - echo "No upstream merge requested\n"; - } - } - } else { - $this->error('git repo does not exist in '.base_path().'/workbench/'.$name); + public function mergeRemote($merge){ + if($merge){ + $this->exec('git merge '.$merge); + } else { + echo "No remote merge requested\n"; + } + } + + public function fetchRemotes($name,array $remotes){ + foreach($remotes as $remoteName=>$location){ + $this->getRemote($name,$remoteName,$location); + } + } + public function getRemote($name,$remoteName,$location){ + echo "get git $name :: $remoteName\n"; + if(!empty($location)){ + //$this->call('command:name', array('argument' => 'foo', '--option' => 'bar')); + chdir(base_path().'/workbench/'.$name); + if(is_dir('.git')){ + if(!$this->verifyRemote($name,$remoteName)){ + $this->exec('git remote add '.$remoteName.' '.$location); + } + if($this->verifyRemote($name,$remoteName)){ + $this->exec('git fetch '.$remoteName); } } else { - $this->error('No Git Upstream Set'); + $this->error('git repo does not exist in '.base_path().'/workbench/'.$name); } } else { - $this->error('No Git Repo Set'); + $this->error('No Git Remote Set'); } } - public function verifyUpstream($name){ + public function verifyUpstream($name,$remoteName){ chdir(base_path().'/workbench/'.$name); $str = shell_exec('git remote -v'); - return (strpos($str,'upstream')!==false); + return (strpos($str,$remoteName)!==false); } // http://stackoverflow.com/questions/1281140/run-process-with-realtime-output-in-php diff --git a/src/config/config.php b/src/config/config.php index dc4569d..f1cbd99 100644 --- a/src/config/config.php +++ b/src/config/config.php @@ -7,7 +7,10 @@ 'packages'=>[ 'vendor/package'=>[ 'git'=>'git@github.com:vendor/devPackage.git', - 'upstream'=>'git@github.com:vendor/masterPackage.git', + 'remotes'=>[ + 'upstream'=>'git@github.com:vendor/masterPackage.git', + 'upstream2'=>'git@github.com:vendor/masterPackage.git', + ] ], ] ); \ No newline at end of file