Skip to content

Commit

Permalink
working on config updates.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpeterson committed Jun 27, 2014
1 parent 58ed9ce commit 2b93b45
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 28 deletions.
9 changes: 6 additions & 3 deletions src/Artistan/Workbench/Commands/InstallCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
52 changes: 28 additions & 24 deletions src/Artistan/Workbench/Helpers/BenchHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/config/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
'packages'=>[
'vendor/package'=>[
'git'=>'[email protected]:vendor/devPackage.git',
'upstream'=>'[email protected]:vendor/masterPackage.git',
'remotes'=>[
'upstream'=>'[email protected]:vendor/masterPackage.git',
'upstream2'=>'[email protected]:vendor/masterPackage.git',
]
],
]
);

0 comments on commit 2b93b45

Please sign in to comment.