Exemple #1
0
 /**
  * Uses git diff to figure out what the diff line position is, based on the error line number.
  * @param Builder $builder
  * @param $file
  * @param $line
  * @return int|null
  */
 protected function getDiffLineNumber(Builder $builder, $file, $line)
 {
     $builder->logExecOutput(false);
     $prNumber = $this->getExtra('pull_request_number');
     $path = $builder->buildPath;
     if (!empty($prNumber)) {
         $builder->executeCommand('cd %s && git diff origin/%s "%s"', $path, $this->getBranch(), $file);
     } else {
         $builder->executeCommand('cd %s && git diff %s^! "%s"', $path, $this->getCommitId(), $file);
     }
     $builder->logExecOutput(true);
     $diff = $builder->getLastOutput();
     $helper = new Diff();
     $lines = $helper->getLinePositions($diff);
     return $lines[$line];
 }
Exemple #2
0
 /**
  * Uses git diff to figure out what the diff line position is, based on the error line number.
  * @param Builder $builder
  * @param $file
  * @param $line
  * @return int|null
  */
 protected function getDiffLineNumber(Builder $builder, $file, $line)
 {
     $line = (int) $line;
     $builder->logExecOutput(false);
     $prNumber = $this->getExtra('pull_request_number');
     $path = $builder->buildPath;
     if (!empty($prNumber)) {
         $builder->executeCommand('cd %s && git diff origin/%s "%s"', $path, $this->getBranch(), $file);
     } else {
         $commitId = $this->getCommitId();
         $compare = $commitId == 'Manual' ? 'HEAD' : $commitId;
         $builder->executeCommand('cd %s && git diff %s^^ "%s"', $path, $compare, $file);
     }
     $builder->logExecOutput(true);
     $diff = $builder->getLastOutput();
     $helper = new Diff();
     $lines = $helper->getLinePositions($diff);
     return isset($lines[$line]) ? $lines[$line] : null;
 }