#!/usr/bin/env php = 6) { $info .= "core = \"$matches[1].x\"\n"; } $info .= "project = \"$project\"\n"; $info .= 'datestamp = "'. time() ."\"\n"; $info .= "\n"; if (!chmod($file, 0644)) { echo "ERROR: chmod($file, 0644) failed\n"; return false; } if (!$info_fd = fopen($file, 'ab')) { echo "ERROR: fopen($file, 'ab') failed\n"; return false; } if (!fwrite($info_fd, $info)) { echo "ERROR: fwrite($file) failed\n"; return false; } return true; } /** * Returns the human-readable version string from a given CVS tag. * * Stolen directly from contributions/modules/cvs_deploy/cvs_deploy.module. */ function get_version_from_tag($tag, $project) { $version = ''; if (!$tag || $tag == 'HEAD') { $version = get_head_version($project); } elseif ($project == 'drupal') { // See if it's a core official release if (preg_match('@^DRUPAL-(\d+)-(\d+)(-.+)?@', $tag, $match)) { $version = $match[1] .'.'. $match[2]; if (isset($match[3])) { // This version's tag has 'extra', so clean that up. $version .= '-'. preg_replace('/[_-]/', '', strtolower($match[3])); } } // -dev snapshot from a core branch elseif (preg_match('@^DRUPAL-(\d+)?@', $tag, $match)) { $version = $match[1] .'.x-dev'; } } else { // Contrib // See if it's a full, official release from a tag: if (preg_match('@^DRUPAL-(\d+)--(\d+)-(\d+)(-.+)?@', $tag, $match)) { $version = $match[1] .'.x-'. $match[2] .'.'. $match[3]; if (isset($match[4])) { // This version's tag has 'extra', so clean that up. $version .= '-'. preg_replace('/[_-]/', '', strtolower($match[4])); } } // If not, see if it's from a branch (like a development snapshot). elseif (preg_match('@^DRUPAL-(\d+)(--(\d+))?@', $tag, $match)) { $version = $match[1] .'.x-'. (isset($match[3]) ? $match[3] : '1') .'.x-dev'; } } return $version; } /** * Get the current version string for the HEAD release of the given project. */ function get_head_version($project) { $data = array(); echo "Fetching version information about the HEAD release for $project\n"; $url = "http://updates.drupal.org/release-history/$project/all"; $history_xml = file_get_contents($url); $xml = new SimpleXMLElement($history_xml); foreach ($xml->releases->children() as $release) { if ($release->tag == 'HEAD') { return $release->version; } } unset($xml); unset($history_xml); return 'HEAD'; }