function _oa_update_get_tag in Open Atrium Core 7.2
For a module in -dev, get the latest tag if on -dev branch.
1 call to _oa_update_get_tag()
- oa_update_update_projects_alter in modules/
oa_update/ oa_update.module - Implements hook_update_projects_alter().
File
- modules/
oa_update/ oa_update.module, line 182 - Code for the oa_update module
Code
function _oa_update_get_tag($module) {
$file = drupal_get_path('module', $module) . '/.git/HEAD';
if (file_exists($file) && ($contents = file_get_contents($file))) {
for ($i = 2; $i > 0; $i--) {
$tagprefix = '7.x-' . $i . '.';
if (strpos($contents, $tagprefix . 'x')) {
$tagsfile = drupal_get_path('module', $module) . '/.git/packed-refs';
if (is_file($tagsfile) && ($tags = file_get_contents($tagsfile))) {
$tags = array_filter(explode("\n", $tags));
foreach ($tags as $key => $tag) {
$pos = strpos($tag, $tagprefix);
if (strpos($tag, $tagprefix) === FALSE || strpos($tag, $tagprefix . 'x') !== FALSE) {
unset($tags[$key]);
}
else {
$tags[$key] = substr($tag, $pos + strlen($tagprefix));
}
}
}
// Add in tagsdir files.
$tagsdir = drupal_get_path('module', $module) . '/.git/refs/tags';
if (is_dir($tagsdir) && ($tagsdirtags = scandir($tagsdir))) {
foreach ($tagsdirtags as $tag) {
if (strpos($tag, $tagprefix) === 0) {
$tags[] = substr($tag, strlen($tagprefix));
}
}
}
sort($tags);
if ($tags) {
return $tagprefix . array_pop($tags);
}
}
}
}
}