public function setInstallInfoFromGit() { $tags = git::getTagsModule($this->installInfo['NAME'], 'template'); if (empty($tags)) { $latest = 'master'; } else { $latest = array_pop($tags); } $this->installInfo['VERSION'] = $latest; }
/** * Get install info for a single template * @param string $template * @return array $val template info */ public function getTemplateInfo($template) { $template_dir = conf::pathHtdocs() . "/templates/{$template}"; $install_file = $template_dir . "/install.inc"; $clone_url = self::getCloneUrlFromPath($template_dir); if (!$clone_url) { return false; } $val = array(); if (file_exists($install_file)) { include $install_file; $val['public_clone_url'] = git::getHttpsFromSsh($clone_url); $val['private_clone_url'] = git::getSshFromHttps($clone_url); if (!self::$master) { if (isset($_INSTALL['VERSION'])) { $val['module_version'] = "{$_INSTALL['VERSION']}"; } else { $tags = git::getTagsModule($template, 'template'); $val['module_version'] = array_pop($tags); } } else { $val['module_version'] = "master"; } $val['module_name'] = $template; } else { $tags = git::getTagsModule($template, 'template'); $latest = array_pop($tags); if (self::$master or !$latest) { $val['module_version'] = "master"; } else { $val['module_version'] = $latest; } $val['module_name'] = $template; $val['public_clone_url'] = git::getHttpsFromSsh($clone_url); $val['private_clone_url'] = git::getSshFromHttps($clone_url); } return $val; }
/** * function for tagging all modules and templates * @param array options from cli env */ function cos_git_tag_all($options) { $profile = new profile(); $version = common::readSingleline('Enter tag version to use '); $modules = $profile->getModules(); foreach ($modules as $key => $val) { $tags = git::getTagsModule($val['module_name'], 'module'); if (in_array($version, $tags)) { common::echoStatus('NOTICE', 'y', "Tag already exists local for module '{$val['module_name']}'."); } $val['new_version'] = $version; cos_git_tag($val, 'module'); } $templates = $profile->getTemplates(); foreach ($templates as $key => $val) { $tags = git::getTagsModule($val['module_name'], 'template'); if (in_array($version, $tags)) { common::echoStatus('NOTICE', 'y', "Tag already exists local for template '{$val['module_name']}'"); } $val['new_version'] = $version; cos_git_tag($val, 'template'); } }
function cos_git_compare_master() { $profile = new profile(); //$version = common::readSingleline('Enter tag version to use '); $modules = $profile->getModules(); foreach ($modules as $key => $val) { $tags = git::getTagsModule($val['module_name'], 'module'); $latest = array_values(array_slice($tags, -1))[0]; common::execCommand("cd ./modules/{$val['module_name']} && git diff {$latest} --raw"); } $templates = $profile->getTemplates(); foreach ($templates as $key => $val) { $tags = git::getTagsModule($val['module_name'], 'template'); $latest = array_values(array_slice($tags, -1))[0]; common::execCommand("cd ./htdocs/templates/{$val['module_name']} && git diff {$latest} --raw"); } }
/** * Get install info for a single template * @param string $template * @return array $val template info */ public function getSingleTemplate($template) { $template_dir = conf::pathHtdocs() . "/templates"; $install_file = $template_dir . "/{$template}/install.inc"; $val = array(); if (file_exists($install_file)) { include $install_file; $val['public_clone_url'] = $_INSTALL['PUBLIC_CLONE_URL']; $val['private_clone_url'] = $_INSTALL['PRIVATE_CLONE_URL']; if (!self::$master) { if (isset($_INSTALL['VERSION'])) { $val['module_version'] = "{$_INSTALL['VERSION']}"; } else { $tags = git::getTagsModule($template, 'template'); $val['module_version'] = array_pop($tags); } } else { $val['module_version'] = "master"; } $val['module_name'] = $template; } else { // check if this a git repo $path = conf::pathHtdocs() . "/templates/{$template}"; $command = "cd {$path} && git config --get remote.origin.url"; exec($command, $output, $ret); if ($ret != 0) { return false; } $git_url = shell_exec($command); $tags = git::getTagsModule($template, 'template'); $latest = array_pop($tags); if (!self::$master) { $val['module_version'] = $latest; } else { $val['module_version'] = "master"; } $val['module_name'] = $template; $val['public_clone_url'] = trim($git_url); } return $val; }