You are here

function hackedProjectWebCVSDownloader::cvs_deploy_get_tag in Hacked! 6.2

Get the CVS tag associated with the given file.

1 call to hackedProjectWebCVSDownloader::cvs_deploy_get_tag()
hackedProjectWebCVSDownloader::download_link in includes/hacked_project.inc
Get information about the CVS location of the project.

File

includes/hacked_project.inc, line 520

Class

hackedProjectWebCVSDownloader
Downloads a project using CVS.

Code

function cvs_deploy_get_tag($file) {
  $version = '';
  static $available = array();
  $match = array();
  if (empty($version)) {

    // The .info file contains no version data. Find the version based
    // on the sticky tag in the local workspace (the CVS/Tag file).
    $cvs_dir = dirname($file) . '/CVS';
    if (is_dir($cvs_dir)) {
      $tag = '';

      // If there's no Tag file, there's no tag, a.k.a. HEAD.
      if (file_exists($cvs_dir . '/Tag')) {
        $tag_file = trim(file_get_contents($cvs_dir . '/Tag'));
        if ($tag_file) {

          // Get the sticky tag for this workspace: strip off the leading 'T'.
          $tag = preg_replace('@^(T|N)@', '', $tag_file);
        }
      }
      $version = $tag;
    }
  }
  elseif (preg_match('/\\$' . 'Name: (.*?)\\$/', $version, $match)) {
    $version = trim($match[1]);
  }
  if (empty($version)) {
    $version = 'HEAD';
  }
  return $version;
}