Skip to content

Commit

Permalink
Merge branch 'master' of ssh://git.freepbx.org/freepbx/devtools
Browse files Browse the repository at this point in the history
Conflicts:
	libraries/xml2Array.class.php
  • Loading branch information
root committed Feb 21, 2018
2 parents affb781 + b22180b commit cf51d2e
Show file tree
Hide file tree
Showing 564 changed files with 255,279 additions and 74,103 deletions.
35 changes: 16 additions & 19 deletions add_tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,30 @@
freepbx::outn("\tFetching remote changes (not applying)...");
$stash = $repo->fetch();
freepbx::out("Done");

$stash = $repo->add_stash();
if(!empty($stash)) {
freepbx::out("\tStashing Uncommited changes..Done");
}
$o = $repo->log_search($greps=array('Module package script', 'Module publish script'), '%h%x09%an%x09%ad%x09%s');
foreach($o as $log) {
$parts = explode("\t",$log);
if(!empty($parts[3]) && preg_match('/(\d*\.\d*)/',$parts[3],$out)) {
if(version_compare($out[1],'2.10','ge') && version_compare($out[1],'2.13','lt')) {
if(preg_match('/('.$out[1].'\S*)/',$parts[3],$out)) {
$tag = str_replace(']','',$out[1]);
$tag = str_replace('.tgz','',$tag);
if(!$repo->tag_exist('release/'.$tag)) {
freepbx::outn("\t\tAdding Tag " .$tag." at ".$parts[0]."...");
//add a tag at this point in time
try {
$repo->add_tag('release/'.$tag,null,$parts[0]);
} catch (Exception $e) {
freepbx::out($e->getMessage());
freepbx::out("Module " . $module . " will not be tagged!");
continue;
}
freepbx::out("Done");
}
if(!empty($parts[3]) && preg_match('/(\d*\.\d*)/',$parts[3],$out)
&& version_compare($out[1],'2.10','ge') && version_compare($out[1],'2.13','lt')
&& preg_match('/('.$out[1].'\S*)/',$parts[3],$out)) {
$tag = str_replace(']','',$out[1]);
$tag = str_replace('.tgz','',$tag);
if(!$repo->tag_exist('release/'.$tag)) {
freepbx::outn("\t\tAdding Tag " .$tag." at ".$parts[0]."...");
//add a tag at this point in time
try {
$repo->add_tag('release/'.$tag,null,$parts[0]);
} catch (Exception $e) {
freepbx::out($e->getMessage());
freepbx::out("Module " . $module . " will not be tagged!");
continue;
}
freepbx::out("Done");
}
}
}
Expand All @@ -95,4 +93,3 @@
freepbx::out("Done");
}
}
?>
74,523 changes: 74,523 additions & 0 deletions binaries/phpunit-4.8.36.phar

Large diffs are not rendered by default.

73,563 changes: 73,563 additions & 0 deletions binaries/phpunit-5.7.21.phar

Large diffs are not rendered by default.

73,917 changes: 0 additions & 73,917 deletions binaries/phpunit.phar

This file was deleted.

1 change: 1 addition & 0 deletions binaries/phpunit.phar
17 changes: 7 additions & 10 deletions checklog.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

//if no modules are set, grab all of them
if (isset($modules) && empty($modules)) {
$allmods = glob($vars['directory'].'/*', GLOB_ONLYDIR);
$allmods = glob($vars['directory'].'/*', GLOB_ONLYDIR);
foreach($allmods as $mod) {
$modules[] = str_replace($vars['directory'] . '/', '', $mod);
}
Expand All @@ -70,7 +70,7 @@
exit(1);
} else {
$repo = Git::open($moddir);

freepbx::out('================================== ' . $module . ' ('.$repo->active_branch().') START =========================================');
freepbx::out(checklog($moddir));
freepbx::out('================================== ' . $module . ' STOP =========================================');
Expand All @@ -80,7 +80,7 @@
/**
* Check Log
*
* This function finds that last tag for the current release and shows you
* This function finds that last tag for the current release and shows you
* any changes between them
*
* @param The git module directory
Expand All @@ -102,10 +102,8 @@ function checklog($moddir) {
//cycle through the tags and create a new array with relavant tags
$tagArray = array();
foreach ($ltags as $tag) {
if(preg_match('/release\/(.*)/i',$tag,$matches)) {
if (strpos($matches[1],$rver) !== false) {
$tagArray[] = $matches[1];
}
if(preg_match('/release\/(.*)/i',$tag,$matches) && (strpos($matches[1],$rver) !== false)) {
$tagArray[] = $matches[1];
}
}

Expand All @@ -115,9 +113,8 @@ function checklog($moddir) {
$htag = array_pop($tagArray);

$tagref = $repo->show_ref_tag($htag);

return $repo->log($tagref,'HEAD');
}
}
return;
}
?>
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"knplabs/github-api": "^1.5",
"mrclay/minify": "^2.3",
"tedivm/jshrink": "^1.1",
"phpseclib/phpseclib": "~2.0"
"phpseclib/phpseclib": "~2.0",
"fzaninotto/faker": "^1.7"
}
}
56 changes: 53 additions & 3 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 7 additions & 4 deletions freepbx_git.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
$repo->delete_all_tags();
} catch (Exception $e) {
freepbx::out($e->getMessage());
continue;
exit(1);
}
freepbx::out('Done');
}
Expand All @@ -123,7 +123,7 @@
$repo->delete_all_tags();
} catch (Exception $e) {
freepbx::out($e->getMessage());
continue;
exit(1);
}
freepbx::out('Done');
}
Expand Down Expand Up @@ -158,7 +158,7 @@
$repo = $stash->getRepo($options['r']);
if ($repo === false) {
freepbx::out("[ERROR] Unable to find ".$options['m']);
exit(0);
exit(1);
}
} else {
try{
Expand All @@ -184,6 +184,9 @@
$dir = $directory.'/'.$options['m'];
freepbx::out("Cloning ".$repo['name'] . " into ".$dir);
$repo = Git::create($dir, $uri);
if(isset($options['switch']) && !empty($options['switch'])) {
freepbx::switchBranch($dir,$options['switch']);
}
$repo->add_merge_driver();
freepbx::out("Done");
$freepbx = new freepbx($username,$password);
Expand Down Expand Up @@ -285,7 +288,7 @@
$pkeys = array("freepbx");
}

$force = isset($options['force']) ? true : false;
$force = isset($options['force']);
$branch = isset($options['switch']) && !empty($options['switch']) ? $options['switch'] : 'develop';
foreach($pkeys as $k) {
$freepbx->setupDevRepos($directory,$force,$mode,$branch,$k);
Expand Down
69 changes: 51 additions & 18 deletions libraries/freepbx.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,14 @@ public static function switchBranch($directory,$branch) {
$repo->checkout($branch);
freepbx::out("Done");
} catch (Exception $e) {
freepbx::out("$branch Doesnt Exist! Attempting to go lower");
$branch = self::getLowerBranch($branch);
$oldBranch = $branch;
$branch = self::getLowerBranch($oldBranch);
freepbx::out("$oldBranch Doesnt Exist!");
if($branch === false) {
freepbx::outn("\tCan't find any branch to work with skipping...");
} else {
freepbx::out("Attempting to go lower to $branch");
self::switchBranch($directory,$branch);
}
}
if(!empty($stash) && empty($final_branch)) {
Expand All @@ -84,6 +88,26 @@ public static function switchBranch($directory,$branch) {
* @return bool
*/
public static function refreshRepo($directory, $remote = 'origin', $final_branch = null) {
$rawname = basename($directory);
if($rawname === 'framework') {
freepbx::out("Refusing to refresh framework as it will break everything. Do it manually");
return true;
}
exec('fwconsole ma list --format=json',$output,$ret);
if($ret !== 0) {
throw new \Exception("Unable to run fwconsole command");
}
$installedModules = array();
foreach($output as $line) {
$out = json_decode(trim($line),true);
if(!empty($out['data']) && is_array($out['data'])) {
foreach($out['data'] as $module) {
if($module[2] === 'Enabled') {
$installedModules[] = $module[0];
}
}
}
}
freepbx::outn("Attempting to open ".$directory."...");
//Attempt to open the module as a git repo, bail if it's not a repo
try {
Expand Down Expand Up @@ -111,7 +135,7 @@ public static function refreshRepo($directory, $remote = 'origin', $final_branch
freepbx::out($activeb);
$lbranches = $repo->list_branches();
$rbranches = $repo->list_remote_branches();
foreach($rbranches as $k => &$rbranch) {
foreach($rbranches as &$rbranch) {
if(preg_match('/'.$remote.'\/(.*)/i',$rbranch)) {
$rbranch = str_replace($remote.'/','',$rbranch);
$rbranch_array[] = $rbranch;
Expand Down Expand Up @@ -162,6 +186,12 @@ public static function refreshRepo($directory, $remote = 'origin', $final_branch
}

$repo->add_merge_driver();

if(in_array($rawname, $installedModules)) {
freepbx::outn("ReInstalling ".$rawname."...");
exec('fwconsole ma install '.$rawname);
freepbx::out("Done");
}
}

/**
Expand Down Expand Up @@ -237,22 +267,22 @@ public static function getLowerBranch($branch) {
return false;
}
$release = $parts[1];
$return = false;
switch($release) {
case version_compare($release, "13.0", ">="):
$parts = explode(".",$release);
$major = $parts[0] - 1;
return "release/".$major.".0";
$return = "release/".$major.".0";
break;
case "12.0":
return "release/2.11";
$return = "release/2.11";
case "2.11":
return "relase/2.10";
$return = "release/2.10";
break;
default:
return false;
break;
}
return false;
return $return;
}

/**
Expand All @@ -271,7 +301,7 @@ function setupSymLinks($directory) {

$dirs = array_filter(glob($directory.'/*'), 'is_dir');

foreach($dirs as $dirkey => $dirpath) {
foreach($dirs as $dirpath) {
if ($fwdir != $dirpath) {
$modlink = $fwmoddir . '/' . basename($dirpath);

Expand Down Expand Up @@ -476,15 +506,18 @@ public static function check_xml($xml) {

foreach ($errors as $error) {
switch ($error->level) {
case LIBXML_ERR_WARNING:
$ereturn = "Warning $error->code: ".trim($error->message);
break;
case LIBXML_ERR_ERROR:
$ereturn = "Error $error->code: ".trim($error->message);
break;
case LIBXML_ERR_FATAL:
$ereturn = "Fatal Error $error->code: ".trim($error->message);
break;
case LIBXML_ERR_WARNING:
$ereturn = "Warning $error->code: ".trim($error->message);
break;
case LIBXML_ERR_ERROR:
$ereturn = "Error $error->code: ".trim($error->message);
break;
case LIBXML_ERR_FATAL:
$ereturn = "Fatal Error $error->code: ".trim($error->message);
break;
default:
$ereturn = "An unknown error occurred";
break;
}
freepbx::out("\t\t\t\tXML ".$ereturn);
}
Expand Down
Loading

0 comments on commit cf51d2e

Please sign in to comment.