Exemplo n.º 1
0
 public function isMatch(GitRepo $gitRepo)
 {
     if (preg_match(';github.com/([^/]+)/([^/]+)/pull/([0-9]+)(|.diff|.patch);', $this->expr, $matches)) {
         $owner = $matches[1];
         $repoName = $matches[2];
         $prNum = $matches[3];
         foreach ($gitRepo->getRemoteUrls() as $remote => $remoteUrl) {
             $baseUrl = preg_replace(';\\.git$;', '', $remoteUrl);
             if ($baseUrl === "https://github.com/{$owner}/{$repoName}") {
                 return TRUE;
             }
             if ($baseUrl === "git@github.com:{$owner}/{$repoName}") {
                 return TRUE;
             }
         }
     } elseif ($this->expr[0] == ';') {
         list(, $regex, $patchFile) = explode(';', $this->expr);
         foreach ($gitRepo->getRemoteUrls() as $remote => $remoteUrl) {
             if (preg_match(";{$regex};", $remoteUrl)) {
                 return TRUE;
             }
         }
         return FALSE;
     } else {
         throw new \RuntimeException("Failed to recognize auto-merge rule: {$this->expr}");
     }
 }
Exemplo n.º 2
0
 public function testCloned_CheckoutMyFeature_Newfile()
 {
     $upstream = $this->createUpstreamRepo();
     ProcessUtil::runOk($this->command("", "git clone file://{$upstream->getPath()} downstream"));
     $downstream = new GitRepo($this->fixturePath . '/downstream');
     ProcessUtil::runOk($downstream->command("git checkout my-feature"));
     $this->assertEquals("example text plus my feature", $downstream->readFile("example.txt"));
     $downstream->writeFile("example-2.txt", "second");
     $this->assertIsCommit($downstream->getCommit());
     $this->assertEquals('my-feature', $downstream->getLocalBranch());
     $this->assertEquals('origin/my-feature', $downstream->getUpstreamBranch());
     $this->assertEquals(FALSE, $downstream->hasUncommittedChanges());
     $this->assertEquals(TRUE, $downstream->hasUntrackedFiles());
     $this->assertEquals(array(), $upstream->getRemotes());
     $this->assertEquals(array('origin'), $downstream->getRemotes());
     $this->assertEquals("file://{$upstream->getPath()}", $downstream->getRemoteUrl('origin'));
     $this->assertEquals(array('origin' => "file://{$upstream->getPath()}"), $downstream->getRemoteUrls());
 }