original_string: protected function computeRebuildVersion($installPath, $branch)
      {
          $version = '';
          $branchPreg = preg_quote($branch);
  
          $process = new Process("cd $installPath; git describe --tags");
          $process->run();
          if ($process->isSuccessful()) {
              $lastTag = strtok($process->getOutput(), "\n");
              // Make sure the tag starts as Drupal formatted (for eg.
              // 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master)
              // then it's on that branch.
              if (preg_match('/^(?<drupalversion>'.$branchPreg.'\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/', $lastTag, $matches)) {
                  if (isset($matches['gitextra'])) {
                      // If we found additional git metadata (in particular, number of commits)
                      // then use that info to build the version string.
                      $version = $matches['drupalversion'].'+'.$matches['numberofcommits'].'dev';
                  } else {
                      // Otherwise, the branch tip is pointing to the same commit as the
                      // last tag on the branch, in which case we use the prior tag and
                      // add '+0-dev' to indicate we're still on a -dev branch.
                      $version = $lastTag.'+0-dev';
                  }
              }
          }
  
          return $version;
      }
code: protected function computeRebuildVersion($installPath, $branch)
      {
          $version = '';
          $branchPreg = preg_quote($branch);
  
          $process = new Process("cd $installPath; git describe --tags");
          $process->run();
          if ($process->isSuccessful()) {
              $lastTag = strtok($process->getOutput(), "\n");
              // Make sure the tag starts as Drupal formatted (for eg.
              // 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master)
              // then it's on that branch.
              if (preg_match('/^(?<drupalversion>'.$branchPreg.'\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/', $lastTag, $matches)) {
                  if (isset($matches['gitextra'])) {
                      // If we found additional git metadata (in particular, number of commits)
                      // then use that info to build the version string.
                      $version = $matches['drupalversion'].'+'.$matches['numberofcommits'].'dev';
                  } else {
                      // Otherwise, the branch tip is pointing to the same commit as the
                      // last tag on the branch, in which case we use the prior tag and
                      // add '+0-dev' to indicate we're still on a -dev branch.
                      $version = $lastTag.'+0-dev';
                  }
              }
          }
  
          return $version;
      }
code_tokens: protected function computeRebuildVersion ( $ installPath , $ branch ) { $ version = '' ; $ branchPreg = preg_quote ( $ branch ) ; $ process = new Process ( "cd $installPath; git describe --tags" ) ; $ process -> run ( ) ; if ( $ process -> isSuccessful ( ) ) { $ lastTag = strtok ( $ process -> getOutput ( ) , "\n" ) ; // Make sure the tag starts as Drupal formatted (for eg. // 7.x-1.0-alpha1) and if we are on a proper branch (ie. not master) // then it's on that branch. if ( preg_match ( '/^(?<drupalversion>' . $ branchPreg . '\.\d+(?:-[^-]+)?)(?<gitextra>-(?<numberofcommits>\d+-)g[0-9a-f]{7})?$/' , $ lastTag , $ matches ) ) { if ( isset ( $ matches [ 'gitextra' ] ) ) { // If we found additional git metadata (in particular, number of commits) // then use that info to build the version string. $ version = $ matches [ 'drupalversion' ] . '+' . $ matches [ 'numberofcommits' ] . 'dev' ; } else { // Otherwise, the branch tip is pointing to the same commit as the // last tag on the branch, in which case we use the prior tag and // add '+0-dev' to indicate we're still on a -dev branch. $ version = $ lastTag . '+0-dev' ; } } } return $ version ; }
docstring: Helper function to compute the rebulid version string for a project.
  
  This does some magic in Git to find the latest release tag along
  the branch we're packaging from, count the number of commits since
  then, and use that to construct this fancy alternate version string
  which is useful for the version-specific dependency support in Drupal
  7 and higher.
  
  NOTE: A similar function lives in git_deploy and in the drupal.org
  packaging script (see DrupalorgProjectPackageRelease.class.php inside
  drupalorg/drupalorg_project/plugins/release_packager). Any changes to the
  actual logic in here should probably be reflected in the other places.
  
  @see drush_pm_git_drupalorg_compute_rebuild_version()
docstring_tokens: Helper function to compute the rebulid version string for a project .