Ejemplo n.º 1
0
        //TODO: check to make sure the author/committer isn't 'root'
        try {
            $repo->push("origin", "release/" . $mver);
        } catch (Exception $e) {
            freepbx::out($e->getMessage());
            freepbx::out("Module " . $module . " will not be pushed!");
            continue;
        }
        freepbx::out("Done");
        freepbx::outn("\tMaster is the same supported release as this branch. Merging this release into master...");
        if (!$vars['debug']) {
            $repo->checkout("master");
            $merged = $repo->pull("origin", "release/" . $mver);
            if (!$merged) {
                freepbx::out("\t\tMerge from release/" . $mver . " into master failed");
                freepbx::out("Module " . $module . " will not be tagged!");
                continue;
            }
            $repo->push("origin", "master");
            $repo->checkout("release/" . $mver);
        }
        freepbx::out("Done");
        freepbx::outn("\tChecking you back into " . $activeb . "...");
        $repo->checkout($activeb);
        freepbx::out("Done");
        break;
    default:
        freepbx::showHelp('update_language.php', $help);
        exit(0);
        break;
}
Ejemplo n.º 2
0
 if ($module == 'fw_langpacks') {
     continue;
 }
 try {
     $repo = Git::open($moduleDir);
 } catch (Exception $e) {
     freepbx::out("Unable to open " . $moduleDir . " as a repo");
     exit(0);
 }
 $branch = $repo->active_branch();
 $stashed = $repo->add_stash();
 freepbx::outn("Checking out master in " . $module . "...");
 $repo->checkout('master');
 $repo->pull('origin', 'master');
 freepbx::out("Done");
 freepbx::outn("\tChecking for i18n folder in " . $module . "...");
 if (!file_exists($moduleDir . "/i18n")) {
     if ($module != "framework") {
         freepbx::out("Not Present, Skipping");
         continue;
     } else {
         freepbx::out("Framework, Special Case");
     }
 } else {
     freepbx::out("found");
 }
 if ($module == "framework") {
     $moduleDir = $moduleDir . '/amp_conf/htdocs/admin';
     $module = "amp";
 }
 foreach (glob($moduleDir . "/i18n/*", GLOB_ONLYDIR) as $langDir) {
Ejemplo n.º 3
0
 /**
  * Setup GIT Repos from Stash
  *
  * Lists all repos from remote project and downloaded them, skipping devtools
  *
  * @param   string $directory Directory to work with
  * @param   bool $force True or False on whether to rm -Rf and then recreate the repo
  * @return  array
  */
 function setupDevRepos($directory, $force = false, $mode = 'ssh', $branch = 'master', $project_key = 'freepbx')
 {
     $skipr = array('devtools', 'moh_sounds', 'versionupgrade', 'fw_langpacks', 'custom-freepbx-modules', 'sipstation_module');
     $o = $this->stash->getAllRepos($project_key);
     if ($mode == 'http' && version_compare(Git::version(), '1.7.9', '<')) {
         freepbx::out("HTTP Mode is only supported with GIT 1.7.9 or Higher");
         die;
     } elseif ($mode == 'http') {
         Git::enable_credential_cache();
     }
     foreach ($o['values'] as $repos) {
         $dir = $directory . '/' . $repos['name'];
         if (in_array($repos['name'], $skipr)) {
             continue;
         }
         freepbx::outn("Cloning " . $repos['name'] . " into " . $dir . "...");
         if (file_exists($dir) && $force) {
             freepbx::out($dir . " Already Exists but force is enabled so deleting and restoring");
             exec('rm -Rf ' . $dir);
         } elseif (file_exists($dir)) {
             freepbx::out($dir . " Already Exists, Skipping (use --force to force)");
             continue;
         }
         $uri = $mode == 'http' ? $repos['cloneUrl'] : $repos['cloneSSH'];
         $repo = Git::create($dir, $uri);
         $repo->add_merge_driver();
         freepbx::out("Done");
         $obranch = $branch;
         while ($branch) {
             try {
                 freepbx::outn("\tChecking you out into the " . $branch . " branch...");
                 $repo->checkout($branch);
                 freepbx::out("Done");
                 break;
             } catch (Exception $e) {
                 freepbx::out("Doesnt Exist!");
                 $branch = $this->getLowerBranch($branch);
                 if ($branch === false) {
                     try {
                         freepbx::outn("\tChecking you out into the master branch...");
                         $repo->checkout('master');
                         freepbx::out("Done");
                     } catch (Exception $e) {
                         //TODO: error?
                     }
                 }
             }
         }
         $branch = $obranch;
         freepbx::out(" ");
     }
 }
Ejemplo n.º 4
0
#!/usr/bin/env php
<?php 
require_once 'libraries/freepbx.php';
$help = array();
$help[] = array('--directory', 'Directory Location of modules root, always assumed to be ../freepbx from this location');
$freepbx_conf = freepbx::getFreePBXConfig();
if (is_array($freepbx_conf) && !empty($freepbx_conf)) {
    foreach ($freepbx_conf as $key => $value) {
        if (isset($value) && $value != '') {
            $vars[$key] = $value;
        }
    }
}
$vars['directory'] = !empty($vars['repo_directory']) ? $vars['repo_directory'] : '';
$vars['directory'] = !empty($vars['directory']) ? $vars['directory'] : dirname(dirname(__FILE__)) . '/freepbx';
$modules = glob($vars['directory'] . '/*', GLOB_ONLYDIR);
foreach ($modules as $mod_dir) {
    freepbx::outn("Attempting to open module " . basename($mod_dir) . "...");
    try {
        $repo = Git::open($mod_dir);
        freepbx::out("Done");
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        continue;
    }
    $remote = $repo->get_remote_uri('origin');
    if (preg_match('/org\\/freep12/i', $remote)) {
        $newuri = preg_replace('/org\\/freep12/i', 'org/freepbx', $remote);
        $repo->update_remote('origin', $newuri);
    }
}
Ejemplo n.º 5
0
 if (freepbx::version_compare_freepbx((string) $masterXML->version, (string) $branchXML->version, "=")) {
     echo "Master IS already this version\n";
     $merge = false;
 }
 if ($merge) {
     freepbx::outn("Attempting to merge release/" . $options['updatemaster'] . " into master...");
     $repo->checkout("master");
     $merged = $repo->pull("origin", "release/" . $options['updatemaster']);
     if (!$merged) {
         freepbx::out("\t\t\tMerge from release/" . $options['updatemaster'] . " into master failed");
         freepbx::out("Module " . $module . " will not be tagged!");
         continue;
     }
     $repo->push("origin", "master");
     freepbx::out("Done");
     freepbx::outn("Checking you out into release/" . $options['updatemaster'] . "...");
     $repo->checkout("release/" . $options['updatemaster']);
     freepbx::out("Done");
 }
 $organizationApi = $client->api('organization');
 $paginator = new Github\ResultPager($client);
 $parameters = array('freepbx');
 $repos = $paginator->fetchAll($organizationApi, 'repositories', $parameters);
 $core = array();
 foreach ($repos as $repo) {
     $core[] = $repo['name'];
 }
 $paginator = new Github\ResultPager($client);
 $parameters = array('FreePBX-ContributedModules');
 $repos = $paginator->fetchAll($organizationApi, 'repositories', $parameters);
 $contrib = array();
Ejemplo n.º 6
0
    exit(0);
}
$count = 1;
foreach (glob($langRepoPath . '/pot/*.pot') as $pot) {
    $fileinfo = pathinfo($pot);
    $module = $fileinfo['filename'];
    if ($fileinfo['filename'] != 'amp') {
        $moduleDirectory = $directory . "/" . $module;
        $langDirectory = $moduleDirectory . "/i18n";
    } else {
        //framework is different
        $moduleDirectory = $directory . "/framework";
        $langDirectory = $moduleDirectory . "/amp_conf/htdocs/admin/i18n";
    }
    if (file_exists($moduleDirectory)) {
        freepbx::outn('Opening ' . $module . '...');
        freepbx::refreshRepo($moduleDirectory);
        try {
            $repo = Git::open($moduleDirectory);
            freepbx::out("Done");
            $ab = $repo->active_branch();
            $repo->checkout("master");
        } catch (Exception $e) {
            freepbx::out("Skipping");
            continue;
        }
        if (!file_exists($langDirectory)) {
            freepbx::out('WARNING: Creating Missing i18n folder in ' . $module, 1);
            mkdir($langDirectory, 0777, true);
        }
        foreach (glob($langRepoPath . '/po/*', GLOB_ONLYDIR) as $langpath) {
Ejemplo n.º 7
0
}
if (!isset($options['setup']) && isset($options['switch']) && !empty($options['switch'])) {
    foreach (glob($directory . "/*", GLOB_ONLYDIR) as $dir) {
        freepbx::switchBranch($dir, $options['switch']);
    }
    exit(0);
}
if (isset($options['refresh'])) {
    foreach (glob($directory . "/*", GLOB_ONLYDIR) as $dir) {
        freepbx::refreshRepo($dir);
    }
    exit(0);
}
if (isset($options['addmergedriver'])) {
    foreach (glob($directory . "/*", GLOB_ONLYDIR) as $dir) {
        freepbx::outn("Attempting to open " . $dir . "...");
        //Attempt to open the module as a git repo, bail if it's not a repo
        try {
            $repo = Git::open($dir);
            freepbx::out("Done");
        } catch (Exception $e) {
            freepbx::out("Skipping");
            continue;
        }
        $gitatts = $repo->add_merge_driver();
        if (!empty($gitatts)) {
            file_put_contents($dir . '/.gitattributes', $gitatts);
        }
    }
    exit(0);
}
Ejemplo n.º 8
0
function update_devtools()
{
    $mypath = __DIR__;
    freepbx::outn("Updating devtools\n\tOpening devtools...");
    //Attempt to open the module as a git repo, bail if it's not a repo
    try {
        $repo = Git::open($mypath);
        freepbx::out("Done");
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        exit;
    }
    freepbx::outn("\tIm going to update the master branch now...");
    $stashable = $repo->add_stash();
    $repo->fetch();
    try {
        $merged = $repo->pull('origin', 'master');
    } catch (\Exception $e) {
        $merged = false;
    }
    if (!$merged) {
        freepbx::out("\t\t\tMerge from master to this branch failed");
        freepbx::out("Module " . $module . " will not be tagged!");
        exit;
    }
    if ($stashable) {
        $repo->apply_stash();
        $repo->drop_stash();
    }
    freepbx::out("Done. Thanks for using FreePBX!");
}
Ejemplo n.º 9
0
                            freepbx::out($e->getMessage());
                            freepbx::out("Module " . $module . " will not be tagged!");
                            continue;
                        }
                        freepbx::out("Done");
                    }
                }
            }
        }
    }
    try {
        $repo->push($vars['remote'], $repo->active_branch());
    } catch (Exception $e) {
        freepbx::out($e->getMessage());
        freepbx::out("Module " . $module . " will not be tagged!");
        continue;
    }
    freepbx::out("Done");
    if (!empty($stash)) {
        freepbx::outn("\tRestoring Uncommited changes...");
        try {
            $repo->apply_stash();
            $repo->drop_stash();
        } catch (Exception $e) {
            freepbx::out("Failed to restore stash!, Please check your directory");
            freepbx::out("Module " . $module . " will not be tagged!");
            continue;
        }
        freepbx::out("Done");
    }
}