cvs [diff aborted]: no such directory `modules/update_status' Index: modules/update_status/update_status.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/update_status/update_status.module,v retrieving revision 1.35 diff -u -p -r1.35 update_status.module --- modules/update_status/update_status.module 23 May 2007 23:29:32 -0000 1.35 +++ modules/update_status/update_status.module 23 May 2007 23:57:56 -0000 @@ -234,7 +234,7 @@ function update_status_force_status() { /** * Make a CVS version string more human readable if possible. */ -function update_status_make_nice_version($version, &$type) { +function update_status_make_nice_version($version) { $match = array(); // The weird concatenation prevents CVS from 'expanding' this $Name. if (preg_match('/\$'.'Name: (.*?)\$/', $version, $match)) { @@ -242,30 +242,58 @@ function update_status_make_nice_version // make a human-readable version string. We can assume at least // 5.x, which simplifies things. Core doesn't use $Name for // version strings at all, so we can also assume contrib. - $type = 'cvs'; - $version = trim($match[1]); + $version = update_status_get_version_from_tag(trim($match[1])); + } + return $version; +} - // If there's nothing, it must be a HEAD checkout, and therefore, - // we have no idea what the version is. - if (!$version) { - $version = 'HEAD'; - } +/** + * Returns the human-readable version string from a given CVS tag. + */ +function update_status_get_version_from_tag($tag) { + // If there's nothing, it must be a HEAD checkout, and therefore, + // we have no idea what the version is. + if (!$tag) { + $version = 'HEAD'; + } + // See if it's a full, official release from a tag: + else 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). + else if (preg_match('@^DRUPAL-(\d+)(--(\d+))?@', $tag, $match)) { + $version = $match[1] .'.x-'. (isset($match[3]) ? $match[3] : '1') .'.x-dev'; + } + return $version; +} - // See if it's a full, official release from a tag: - else if (preg_match('@^DRUPAL-(\d+)--(\d+)-(\d+)(-.+)?@', $version, $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])); +/** + * Try to figure out what kind of installation we have (official + * release, deploy from CVS, etc). If we don't have any version info + * and this is deployed from CVS, see if we can find the version based + * on the sticky tag in the local workspace (the CVS/Tag file). + */ +function update_status_get_install_type(&$info, $file) { + // Assume an official release unless we detect CVS. + $type = 'official'; + $cvs_dir = dirname($file->filename) .'/CVS'; + if (is_dir($cvs_dir)) { + $type = 'cvs'; + if (!isset($info['version'])) { + $tag_file = trim(file_get_contents($cvs_dir .'/Tag')); + $sticky = ''; + if ($tag_file) { + // Get the sticky tag for this workspace: strip off the leading 'T'. + $sticky = preg_replace('@^T@', '', $tag_file); } - } - - // If not, see if it's from a branch (like a development snapshot). - else if (preg_match('@^DRUPAL-(\d+)(--(\d+))?@', $version, $match)) { - $version = $match[1] .'.x-'. (isset($match[3]) ? $match[3] : '1') .'.x-dev'; + $info['version'] = update_status_get_version_from_tag($sticky); } } - return $version; + return $type; } /** @@ -323,24 +351,25 @@ function update_status_get_projects() { if (!array_key_exists($info['project'], $projects)) { // Only process this if we haven't done this project, since a single // project can have multiple modules. - $type = 'official'; + + // This checks if it's a CVS install or not, and populates the + // $info['version'] field if we have a sticky tagged CVS + // workspace but no version data in the .info file. + $type = update_status_get_install_type($info, $file); + if (!array_key_exists('version', $info)) { $type = 'unknown'; $info['version'] = t('Unknown'); } - if (strpos($info['version'], '$Name') !== FALSE) { - $info['version'] = update_status_make_nice_version($info['version'], $type); - } + // Try to sanitize and make the version string more + // human-readable, for example, if this is from CVS and we've + // got a version string using $Name and the CVS tag or branch. + $info['version'] = update_status_make_nice_version($info['version']); - if (strpos($info['version'], '-dev') !== FALSE) { + if ($type == 'official' && strpos($info['version'], '-dev') !== FALSE) { $type = 'dev'; } - else if ($info['project'] == 'drupal' && strpos($info['version'], 'dev') !== FALSE) { - // If we didn't see '-dev', and this is core, and we see just - // 'dev', we know this came from CVS. - $type = 'cvs'; - } if (!array_key_exists('project status url', $info)) { $info['project status url'] = UPDATE_STATUS_DEFAULT_URL;