function it_should_not_run_when_there_are_no_unstaged_changes(Repository $repository, Diff $unstaged)
 {
     $event = new RunnerEvent(new TasksCollection(), new RunContext(new FilesCollection()), new TaskResultCollection());
     $unstaged->getFiles()->willReturn([]);
     $this->saveStash($event);
     $this->popStash($event);
     $repository->run(Argument::cetera())->shouldNotBeCalled();
 }
Пример #2
0
 protected function verifyCreateCommitDiff(Diff $diff)
 {
     $files = $diff->getFiles();
     $this->assertEquals(2, count($files), "1 file in diff");
     $this->assertTrue($files[0]->isCreation(), "script_A.php created");
     $this->assertEquals(null, $files[0]->getOldName(), "First file name is a new file");
     $this->assertEquals('script_A.php', $files[0]->getNewName(), "First file name is script_A.php");
     $this->assertEquals(null, $files[0]->getOldMode(), "First file mode is a new file");
     $this->assertEquals('100644', $files[0]->getNewMode(), "First file mode is correct");
     $this->assertEquals(1, $files[0]->getAdditions(), "1 line added");
     $this->assertEquals(0, $files[0]->getDeletions(), "0 lines deleted");
 }
Пример #3
0
 /**
  * @param Diff $diff
  *
  * @return FilesCollection
  */
 private function parseFilesFromDiff(Diff $diff)
 {
     $files = [];
     /** @var File $file */
     foreach ($diff->getFiles() as $file) {
         if ($file->isDeletion()) {
             continue;
         }
         $fileName = $file->isRename() ? $file->getNewName() : $file->getName();
         $files[] = new SplFileInfo($fileName, dirname($fileName), $fileName);
     }
     return new FilesCollection($files);
 }
Пример #4
0
 /**
  * @return Diff
  */
 public function getDiff()
 {
     $args = array('-r', '-p', '-m', '-M', '--no-commit-id', '--full-index', $this->revision);
     $diff = Diff::parse($this->repository->run('diff-tree', $args));
     $diff->setRepository($this->repository);
     return $diff;
 }
Пример #5
0
 /**
  * @param string $file Path to file
  *
  * @return Diff
  */
 public function getDiffFile($file)
 {
     $args = ['-r', '-p', '-m', '-M', '--no-commit-id', '--full-index', $this->revision, '--', $this->repository->getWikiDir() . $file];
     $diff = Diff::parse($this->repository->run('diff-tree', $args));
     $diff->setRepository($this->repository);
     return $diff;
 }
Пример #6
0
 /**
  * Build the diff structure using optional modifications
  *
  * @return array
  */
 public function build()
 {
     $this->diffFiles = $this->diff->getFiles();
     $this->addLine = $this->addLine ?: $this->defaultLineAdd();
     $this->removeLine = $this->removeLine ?: $this->defaultLineRemove();
     $this->contextLine = $this->contextLine ?: $this->defaultLineContext();
     /**
      * @var File $file
      * @var FileChange $change
      */
     foreach ($this->diffFiles as $file) {
         $this->files[$file->getName()] = [];
         $changes = $file->getChanges();
         foreach ($changes as $change) {
             $this->files[$file->getName()]['names']['old'] = $file->getOldName();
             $this->files[$file->getName()]['names']['new'] = $file->getNewName();
             foreach ($change->getLines() as $data) {
                 list($type, $line) = $data;
                 $this->files[$file->getName()]['lines'][] = $this->buildLine($type, $line);
             }
         }
     }
     return $this->files;
 }
Пример #7
0
 /**
  * @return Diff
  */
 public function getDiff($revisions)
 {
     if (null !== $revisions && !$revisions instanceof RevisionList) {
         $revisions = new RevisionList($this, $revisions);
     }
     $args = array_merge(array('-r', '-p', '-m', '-M', '--no-commit-id', '--full-index'), $revisions->getAsTextArray());
     $diff = Diff::parse($this->run('diff', $args));
     $diff->setRepository($this);
     return $diff;
 }
 public function getDiffStaged()
 {
     $diff = Diff::parse($this->run('diff', array('-r', '-p', '-m', '-M', '--full-index', '--staged')));
     $diff->setRepository($this->repository);
     return $diff;
 }