Example #1
0
 /**
  * Update post-commit hooks
  *
  * @param Project $project project for wich post-commit hooks will be updated
  *
  * @return Boolean
  */
 public function updatePostCommit($project)
 {
     $unix_group_name = $project->getUnixName(false);
     // May contain upper-case letters
     $cvs_dir = $GLOBALS['cvs_prefix'] . "/" . $unix_group_name;
     if ($project->isCVSTracked()) {
         // hook for commit tracking in cvs loginfo file
         $filename = "{$cvs_dir}/CVSROOT/loginfo";
         $file_array = file($filename);
         if (!in_array($this->block_marker_start, $file_array)) {
             if ($this->useCVSNT()) {
                 $command = "ALL " . $GLOBALS['codendi_bin_prefix'] . "/log_accum -T {$unix_group_name} -C {$unix_group_name} -s %{sVv}";
             } else {
                 $command = "ALL (" . $GLOBALS['codendi_bin_prefix'] . "/log_accum -T {$unix_group_name} -C {$unix_group_name} -s %{sVv})>/dev/null 2>&1";
             }
             $this->_RcsCheckout($filename);
             $this->addBlock($filename, $command);
             $this->_RcsCommit($filename);
             $this->recurseChownChgrp($cvs_dir . "/CVSROOT", $this->getHTTPUser(), $unix_group_name);
         }
         // hook for commit tracking in cvs commitinfo file
         $filename = "{$cvs_dir}/CVSROOT/commitinfo";
         $file_array = file($filename);
         if (!in_array($this->block_marker_start, $file_array)) {
             $this->_RcsCheckout($filename);
             $this->addBlock($filename, "ALL " . $GLOBALS['codendi_bin_prefix'] . "/commit_prep -T {$unix_group_name} -r");
             $this->_RcsCommit($filename);
             $this->recurseChownChgrp($cvs_dir . "/CVSROOT", $this->getHTTPUser(), $unix_group_name);
         }
     } else {
         // Remove Codendi blocks if needed
         $filename = "{$cvs_dir}/CVSROOT/loginfo";
         $file_array = file($filename);
         if (in_array($this->block_marker_start, $file_array)) {
             $this->removeBlock($filename);
         }
         $filename = "{$cvs_dir}/CVSROOT/commitinfo";
         $file_array = file($filename);
         if (in_array($this->block_marker_start, $file_array)) {
             $this->removeBlock($filename);
         }
     }
     return true;
 }