コード例 #1
0
ファイル: PushCommandTest.php プロジェクト: totten/git-scan
 /**
  * @param string $checkout the treeish to checkout
  * @return GitRepo the upstream repo has:
  *  - a master branch
  *  - a new (unmerged) feature branch (1.x-master)
  *  - a tag of after the merge of 1.x-master-1 (0.2)
  */
 protected function createUpstreamRepo($checkout = 'master')
 {
     $gitRepo = new GitRepo($this->fixturePath . '/upstream');
     if (!$gitRepo->init()) {
         throw new \RuntimeException("Error: Repo already exists!");
     }
     $gitRepo->commitFile("example.txt", "example text");
     ProcessUtil::runOk($gitRepo->command("git tag 0.1"));
     $gitRepo->commitFile("changelog.txt", "new in v0.2: don't know yet!");
     ProcessUtil::runOk($gitRepo->command("git checkout -b 1.x-master"));
     $gitRepo->commitFile("example.txt", "example text plus my feature");
     // Validate
     ProcessUtil::runOk($gitRepo->command("git checkout master"));
     $this->assertEquals("example text", $gitRepo->readFile("example.txt"));
     ProcessUtil::runOk($gitRepo->command("git checkout 1.x-master"));
     $this->assertEquals("example text plus my feature", $gitRepo->readFile("example.txt"));
     // Wrap up
     ProcessUtil::runOk($gitRepo->command("git checkout {$checkout}"));
     return $gitRepo;
 }
コード例 #2
0
ファイル: DiffCommandTest.php プロジェクト: totten/git-scan
 public function testDiff_multiCase_json()
 {
     $this->createExampleRepo($this->fixturePath . '/orig/foo/repo-change-me');
     $this->createExampleRepo($this->fixturePath . '/orig/bar/repo-keep-me');
     $this->createExampleRepo($this->fixturePath . '/orig/whiz/repo-delete-me');
     ProcessUtil::runOk($this->command($this->fixturePath, "cp -r orig changed"));
     ProcessUtil::runOk($this->command($this->fixturePath, "rm -rf changed/whiz/repo-delete-me"));
     $this->createExampleRepo($this->fixturePath . '/changed/bang/repo-add-me');
     $changeMe = new GitRepo($this->fixturePath . '/changed/foo/repo-change-me');
     ProcessUtil::runOk($changeMe->command("git checkout -b feature-branch"));
     $changeMe->commitFile("new-stuff.txt", "This is a change to the repo!");
     $commandTester = $this->createCommandTester(array('command' => 'diff', 'from' => "{$this->fixturePath}/orig", 'to' => "{$this->fixturePath}/changed", '--format' => 'json'));
     $json = $commandTester->getDisplay(FALSE);
     $actualDoc = json_decode($json, TRUE);
     $expectRegexp = array(array('path' => ':^bang/repo-add-me$:', 'status' => '/^\\+$/', 'from' => '/^$/', 'to' => '/^master \\([0-9a-f]+\\)$/', 'changes' => '/^\\(Added repository\\)$/'), array('path' => ':^bar/repo-keep-me$:', 'status' => '/^ $/', 'from' => '/^master \\([0-9a-f]+\\)$/', 'to' => '/^master \\([0-9a-f]+\\)$/', 'changes' => '/^$/'), array('path' => ':^foo/repo-change-me$:', 'status' => '/^M$/', 'from' => '/^master \\([0-9a-f]+\\)$/', 'to' => '/^feature-branch \\([0-9a-f]+\\)$/', 'changes' => '/^1 \\[.*\\]$/'), array('path' => ':^whiz/repo-delete-me$:', 'status' => '/^-$/', 'from' => '/^master \\([0-9a-f]+\\)$/', 'to' => '/^$/', 'changes' => '/^\\(Removed repository\\)$/'));
     $this->assertEquals(count($actualDoc), count($expectRegexp), "Unexpected number of rows: " . print_r($actualDoc, TRUE));
     foreach ($expectRegexp as $offset => $expectRow) {
         foreach ($expectRow as $key => $pattern) {
             $this->assertRegExp($pattern, $actualDoc[$offset][$key]);
         }
     }
 }
コード例 #3
0
 /**
  * @param \GitScan\GitRepo $gitRepo
  * @param $name
  * @return string
  *   Path to the patch file.
  */
 protected function createPatchFile(GitRepo $gitRepo, $name)
 {
     $file = $this->fixturePath . '/' . $name . '.patch';
     ProcessUtil::runOk($gitRepo->command("git checkout master -b tmp"));
     $gitRepo->commitFile("changelog.txt", "new in v0.3: the future has been patched!");
     ProcessUtil::runOk($gitRepo->command("git format-patch --stdout HEAD~1 > {$file}"));
     ProcessUtil::runOk($gitRepo->command("git checkout master"));
     return $file;
 }