/** * @test */ public function cloneDedicatedCommitCreatesGitRepositoryContainingExactlyThatCommit() { $this->skipTestIfGitCommandForTestingDoesNotExist(); $this->proxy->init()->execute(); file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")), "Dr. Strangelove Or How I Stopped Worrying And Love The Bomb"); file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt")), "2001 - A Space Odyssey"); $this->proxy->add()->setPath(".")->execute(); $this->proxy->commit()->setMessage("[TASK] Initial commit")->execute(); $this->proxy->tag()->setSign(false)->setName("Version01")->execute(); $expectedFirstCommitHash = $this->proxy->log()->setMaxCount(1)->setFormat("%H")->execute()->getRawResult(); $expectedFirstCommitHash = trim($expectedFirstCommitHash); unlink(Files::concatenatePaths(array($this->repositoryRootPath, "film02.txt"))); file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film01.txt")), "Lolita"); file_put_contents(Files::concatenatePaths(array($this->repositoryRootPath, "film03.txt")), "A Clockwork Orange"); $this->proxy->add()->setPath(".")->execute(); $this->proxy->commit()->setMessage("[CHG] Change film texts")->execute(); $this->proxy->tag()->setSign(false)->setName("Version02")->execute(); $expectedSecondCommitHash = $this->proxy->log()->setMaxCount(1)->setFormat("%H")->execute()->getRawResult(); $expectedSecondCommitHash = trim($expectedSecondCommitHash); $this->proxy->cloneRepository()->setDepth(1)->setBranch("Version01")->setRepository('file://' . $this->repositoryRootPath)->setDirectory($this->remoteRepositoryRootPath)->execute(); $expectedCommits = sprintf("%s [TASK] Initial commit\n", $expectedFirstCommitHash); $actualCommits = $this->runGitCommandForAssertion(sprintf("%s --git-dir=%s/.git log --pretty=\"oneline\"", $this->pathToGitCommand, $this->remoteRepositoryRootPath)); $this->assertSame($expectedCommits, $actualCommits); Files::emptyDirectoryRecursively($this->remoteRepositoryRootPath); $this->proxy->cloneRepository()->setDepth(1)->setBranch("Version02")->setRepository('file://' . $this->repositoryRootPath)->setDirectory($this->remoteRepositoryRootPath)->execute(); $expectedCommits = sprintf("%s [CHG] Change film texts\n", $expectedSecondCommitHash); $actualCommits = $this->runGitCommandForAssertion(sprintf("%s --git-dir=%s/.git log --pretty=\"oneline\"", $this->pathToGitCommand, $this->remoteRepositoryRootPath)); $this->assertSame($expectedCommits, $actualCommits); }
/** * @test */ public function commandRendersValidCommand() { $this->prepareShellCommandExpectations(); $this->proxy->cloneRepository()->setRepository('file:///path/to/a/repository/of/chocolate.git')->setDirectory('/path/to/checked/out/chocolate/')->execute(); $this->proxy->cloneRepository()->setRepository('file:///path/to/a/repository/of/chocolate.git')->setDirectory('/path/to/checked/out/chocolate/')->setDepth(1)->setBranch('YummyTag')->execute(); $this->proxy->checkout()->setForce(true)->setQuiet(true)->setCommit('c0ca3ae2f34ef4dc024093f92547b43a4d9bd58a')->execute(); $this->proxy->log()->setMaxCount(10)->execute(); $this->proxy->log()->setFormat('%H')->execute(); $this->proxy->config()->setGlobal(true)->setUserName('Bud Spencer')->execute(); $this->proxy->config()->setGlobal(true)->setEmail('*****@*****.**')->execute(); $this->proxy->remote()->remove()->setName('origin')->execute(); $this->proxy->remote()->add()->setName('origin')->setUrl('file:///tmp/punktde.git')->execute(); $this->proxy->init()->setBare(true)->setShared(true)->execute(); $this->proxy->push()->setTags()->setRemote('origin')->setRefspec('master')->execute(); $this->proxy->tag()->setName('v1.2.3')->setSign(true)->setAnnotate(true)->setMessage('Release')->execute(); $this->proxy->commit()->setAllowEmpty(true)->setMessage('This is a very empty commit!')->execute(); $this->proxy->commit()->setMessage('This is a very cool message!')->execute(); $this->proxy->add()->setPath('.')->setAll(true)->execute(); $this->proxy->status()->setShort(true)->execute(); $this->proxy->log()->setNameOnly(true)->execute(); }