Make it clear what is going on when a vcs folder is missing, fixes #2108
parent
3ffad59719
commit
771233a5a0
|
@ -16,14 +16,16 @@ problems:
|
||||||
submodules. This is problematic because they are not real submodules, and you
|
submodules. This is problematic because they are not real submodules, and you
|
||||||
will run into issues.
|
will run into issues.
|
||||||
|
|
||||||
If you really feel like you must do this, you have three options:
|
If you really feel like you must do this, you have a few options:
|
||||||
|
|
||||||
1. Limit yourself to installing tagged releases (no dev versions), so that you
|
1. Limit yourself to installing tagged releases (no dev versions), so that you
|
||||||
only get zipped installs, and avoid problems with the git "submodules".
|
only get zipped installs, and avoid problems with the git "submodules".
|
||||||
2. Remove the `.git` directory of every dependency after the installation, then
|
2. Use --prefer-dist or set `preferred-install` to `dist` in your
|
||||||
you can add them to your git repo. You can do that with `rm -rf vendor/**/.git`
|
[config](../04-schema.md#config).
|
||||||
but this means you will have to delete those dependencies from disk before
|
3. Remove the `.git` directory of every dependency after the installation, then
|
||||||
running composer update.
|
you can add them to your git repo. You can do that with `rm -rf vendor/**/.git`
|
||||||
3. Add a .gitignore rule (`vendor/.git`) to ignore all the vendor `.git` folders.
|
but this means you will have to delete those dependencies from disk before
|
||||||
This approach does not require that you delete dependencies from disk prior to
|
running composer update.
|
||||||
running a composer update.
|
4. Add a .gitignore rule (`vendor/.git`) to ignore all the vendor `.git` folders.
|
||||||
|
This approach does not require that you delete dependencies from disk prior to
|
||||||
|
running a composer update.
|
||||||
|
|
|
@ -53,6 +53,9 @@ class GitDownloader extends VcsDownloader
|
||||||
{
|
{
|
||||||
$this->cleanEnv();
|
$this->cleanEnv();
|
||||||
$path = $this->normalizePath($path);
|
$path = $this->normalizePath($path);
|
||||||
|
if (!is_dir($path.'/.git')) {
|
||||||
|
throw new \RuntimeException('The .git directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information');
|
||||||
|
}
|
||||||
|
|
||||||
$ref = $target->getSourceReference();
|
$ref = $target->getSourceReference();
|
||||||
$this->io->write(" Checking out ".$ref);
|
$this->io->write(" Checking out ".$ref);
|
||||||
|
|
|
@ -45,6 +45,11 @@ class HgDownloader extends VcsDownloader
|
||||||
$url = escapeshellarg($target->getSourceUrl());
|
$url = escapeshellarg($target->getSourceUrl());
|
||||||
$ref = escapeshellarg($target->getSourceReference());
|
$ref = escapeshellarg($target->getSourceReference());
|
||||||
$this->io->write(" Updating to ".$target->getSourceReference());
|
$this->io->write(" Updating to ".$target->getSourceReference());
|
||||||
|
|
||||||
|
if (!is_dir($path.'/.hg')) {
|
||||||
|
throw new \RuntimeException('The .hg directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information');
|
||||||
|
}
|
||||||
|
|
||||||
$command = sprintf('hg pull %s && hg up %s', $url, $ref);
|
$command = sprintf('hg pull %s && hg up %s', $url, $ref);
|
||||||
if (0 !== $this->process->execute($command, $ignoredOutput, $path)) {
|
if (0 !== $this->process->execute($command, $ignoredOutput, $path)) {
|
||||||
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
throw new \RuntimeException('Failed to execute ' . $command . "\n\n" . $this->process->getErrorOutput());
|
||||||
|
|
|
@ -41,6 +41,10 @@ class SvnDownloader extends VcsDownloader
|
||||||
$url = $target->getSourceUrl();
|
$url = $target->getSourceUrl();
|
||||||
$ref = $target->getSourceReference();
|
$ref = $target->getSourceReference();
|
||||||
|
|
||||||
|
if (!is_dir($path.'/.svn')) {
|
||||||
|
throw new \RuntimeException('The .svn directory is missing from '.$path.', see http://getcomposer.org/commit-deps for more information');
|
||||||
|
}
|
||||||
|
|
||||||
$this->io->write(" Checking out " . $ref);
|
$this->io->write(" Checking out " . $ref);
|
||||||
$this->execute($url, "svn switch", sprintf("%s/%s", $url, $ref), $path);
|
$this->execute($url, "svn switch", sprintf("%s/%s", $url, $ref), $path);
|
||||||
}
|
}
|
||||||
|
|
|
@ -221,6 +221,10 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
||||||
|
|
||||||
|
$tmpDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'test-git-update';
|
||||||
|
if (!is_dir($tmpDir.'/.git')) {
|
||||||
|
mkdir($tmpDir.'/.git', true, 0777);
|
||||||
|
}
|
||||||
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceReference')
|
->method('getSourceReference')
|
||||||
|
@ -234,23 +238,27 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($this->winCompat("git remote -v")))
|
->with($this->equalTo($this->winCompat("git status --porcelain --untracked-files=no")))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
$processExecutor->expects($this->at(1))
|
$processExecutor->expects($this->at(1))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitUpdateCommand))
|
->with($this->equalTo($this->winCompat("git remote -v")))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
$processExecutor->expects($this->at(2))
|
$processExecutor->expects($this->at(2))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo('git branch -r'))
|
->with($this->equalTo($expectedGitUpdateCommand))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
$processExecutor->expects($this->at(3))
|
$processExecutor->expects($this->at(3))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat('composerPath')))
|
->with($this->equalTo('git branch -r'))
|
||||||
|
->will($this->returnValue(0));
|
||||||
|
$processExecutor->expects($this->at(4))
|
||||||
|
->method('execute')
|
||||||
|
->with($this->equalTo($this->winCompat("git checkout 'ref' && git reset --hard 'ref'")), $this->equalTo(null), $this->equalTo($this->winCompat($tmpDir)))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
|
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
|
||||||
$downloader->update($packageMock, $packageMock, 'composerPath');
|
$downloader->update($packageMock, $packageMock, $tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -260,6 +268,10 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
{
|
{
|
||||||
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
$expectedGitUpdateCommand = $this->winCompat("git remote set-url composer 'git://github.com/composer/composer' && git fetch composer && git fetch --tags composer");
|
||||||
|
|
||||||
|
$tmpDir = sys_get_temp_dir().DIRECTORY_SEPARATOR.'test-git-update';
|
||||||
|
if (!is_dir($tmpDir.'/.git')) {
|
||||||
|
mkdir($tmpDir.'/.git', true, 0777);
|
||||||
|
}
|
||||||
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceReference')
|
->method('getSourceReference')
|
||||||
|
@ -270,15 +282,19 @@ class GitDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($this->winCompat("git remote -v")))
|
->with($this->equalTo($this->winCompat("git status --porcelain --untracked-files=no")))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
$processExecutor->expects($this->at(1))
|
$processExecutor->expects($this->at(1))
|
||||||
|
->method('execute')
|
||||||
|
->with($this->equalTo($this->winCompat("git remote -v")))
|
||||||
|
->will($this->returnValue(0));
|
||||||
|
$processExecutor->expects($this->at(2))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitUpdateCommand))
|
->with($this->equalTo($expectedGitUpdateCommand))
|
||||||
->will($this->returnValue(1));
|
->will($this->returnValue(1));
|
||||||
|
|
||||||
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
|
$downloader = $this->getDownloaderMock(null, new Config(), $processExecutor);
|
||||||
$downloader->update($packageMock, $packageMock, 'composerPath');
|
$downloader->update($packageMock, $packageMock, $tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
|
|
|
@ -84,6 +84,11 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
|
|
||||||
public function testUpdate()
|
public function testUpdate()
|
||||||
{
|
{
|
||||||
|
$tmpDir = sys_get_temp_dir().'/test-hg-update';
|
||||||
|
if (!is_dir($tmpDir.'/.hg')) {
|
||||||
|
mkdir($tmpDir.'/.hg', true, 0777);
|
||||||
|
}
|
||||||
|
|
||||||
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
$packageMock = $this->getMock('Composer\Package\PackageInterface');
|
||||||
$packageMock->expects($this->any())
|
$packageMock->expects($this->any())
|
||||||
->method('getSourceReference')
|
->method('getSourceReference')
|
||||||
|
@ -93,14 +98,19 @@ class HgDownloaderTest extends \PHPUnit_Framework_TestCase
|
||||||
->will($this->returnValue('https://github.com/l3l0/composer'));
|
->will($this->returnValue('https://github.com/l3l0/composer'));
|
||||||
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
$processExecutor = $this->getMock('Composer\Util\ProcessExecutor');
|
||||||
|
|
||||||
$expectedGitCommand = $this->getCmd("hg pull 'https://github.com/l3l0/composer' && hg up 'ref'");
|
$expectedHgCommand = $this->getCmd("hg st");
|
||||||
$processExecutor->expects($this->at(0))
|
$processExecutor->expects($this->at(0))
|
||||||
->method('execute')
|
->method('execute')
|
||||||
->with($this->equalTo($expectedGitCommand))
|
->with($this->equalTo($expectedHgCommand))
|
||||||
|
->will($this->returnValue(0));
|
||||||
|
$expectedHgCommand = $this->getCmd("hg pull 'https://github.com/l3l0/composer' && hg up 'ref'");
|
||||||
|
$processExecutor->expects($this->at(1))
|
||||||
|
->method('execute')
|
||||||
|
->with($this->equalTo($expectedHgCommand))
|
||||||
->will($this->returnValue(0));
|
->will($this->returnValue(0));
|
||||||
|
|
||||||
$downloader = $this->getDownloaderMock(null, null, $processExecutor);
|
$downloader = $this->getDownloaderMock(null, null, $processExecutor);
|
||||||
$downloader->update($packageMock, $packageMock, 'composerPath');
|
$downloader->update($packageMock, $packageMock, $tmpDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRemove()
|
public function testRemove()
|
||||||
|
|
Loading…
Reference in New Issue