diff --git a/composer.json b/composer.json index 084131039..7d846b59a 100644 --- a/composer.json +++ b/composer.json @@ -27,7 +27,8 @@ "seld/jsonlint": "1.*", "symfony/console": "2.1.*", "symfony/finder": "2.1.*", - "symfony/process": "2.1.*" + "symfony/process": "2.1.*", + "symfony/filesystem": "2.1.*" }, "suggest": { "ext-zip": "Enabling the zip extension allows you to unzip archives, and allows gzip compression of all internet traffic", diff --git a/composer.lock b/composer.lock index 83aa81a1b..8c92abe72 100644 --- a/composer.lock +++ b/composer.lock @@ -1,5 +1,5 @@ { - "hash": "1023850095295cc1307c2219a0382930", + "hash": "f9e033da0cd0bd8d9fdb2e5999a7b20e", "packages": [ { "name": "justinrainbow/json-schema", @@ -103,6 +103,53 @@ "description": "Symfony Console Component", "homepage": "http://symfony.com" }, + { + "name": "symfony/filesystem", + "version": "v2.1.2", + "target-dir": "Symfony/Component/Filesystem", + "source": { + "type": "git", + "url": "https://github.com/symfony/Filesystem", + "reference": "v2.1.2" + }, + "dist": { + "type": "zip", + "url": "https://github.com/symfony/Filesystem/zipball/v2.1.2", + "reference": "v2.1.2", + "shasum": "" + }, + "require": { + "php": ">=5.3.3" + }, + "time": "2012-08-22 06:48:41", + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "2.1-dev" + } + }, + "installation-source": "dist", + "autoload": { + "psr-0": { + "Symfony\\Component\\Filesystem": "" + } + }, + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Fabien Potencier", + "email": "fabien@symfony.com" + }, + { + "name": "Symfony Community", + "homepage": "http://symfony.com/contributors" + } + ], + "description": "Symfony Filesystem Component", + "homepage": "http://symfony.com" + }, { "name": "symfony/finder", "version": "v2.1.1", diff --git a/src/Composer/Command/CreateProjectCommand.php b/src/Composer/Command/CreateProjectCommand.php index 6d7835e46..97bbcb8bf 100644 --- a/src/Composer/Command/CreateProjectCommand.php +++ b/src/Composer/Command/CreateProjectCommand.php @@ -26,6 +26,8 @@ use Symfony\Component\Console\Input\InputArgument; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputOption; use Symfony\Component\Console\Output\OutputInterface; +use Symfony\Component\Filesystem\Filesystem; +use Symfony\Component\Finder\Finder; use Composer\Json\JsonFile; use Composer\Util\RemoteFilesystem; use Composer\Package\Version\VersionParser; @@ -50,7 +52,8 @@ class CreateProjectCommand extends Command new InputOption('repository-url', null, InputOption::VALUE_REQUIRED, 'Pick a different repository url to look for the package.'), new InputOption('dev', null, InputOption::VALUE_NONE, 'Whether to install dependencies for development.'), new InputOption('no-custom-installers', null, InputOption::VALUE_NONE, 'Whether to disable custom installers.'), - new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.') + new InputOption('no-scripts', null, InputOption::VALUE_NONE, 'Whether to prevent execution of all defined scripts in the root package.'), + new InputOption('keep-vcs', null, InputOption::VALUE_NONE, 'Whether to prevent deletion vcs folder.'), )) ->setHelp(<<create-project command creates a new project from a given @@ -84,11 +87,12 @@ EOT $input->getOption('dev'), $input->getOption('repository-url'), $input->getOption('no-custom-installers'), - $input->getOption('no-scripts') + $input->getOption('no-scripts'), + $input->getOption('keep-vcs') ); } - public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $preferSource = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false) + public function installProject(IOInterface $io, $packageName, $directory = null, $packageVersion = null, $preferSource = false, $installDevPackages = false, $repositoryUrl = null, $disableCustomInstallers = false, $noScripts = false, $keepVcs = false) { $config = Factory::createConfig(); @@ -183,6 +187,25 @@ EOT } $installer->run(); + + if (!$keepVcs && ( + !$io->isInteractive() || + $io->askConfirmation('Do you want remove all previous VCS history ? [yes]: ', true) + ) + ) { + $finder = new Finder(); + $finder->in($directory)->ignoreVCS(false)->ignoreDotFiles(false); + foreach (array('.svn', '_svn', 'CVS', '_darcs', '.arch-params', '.monotone', '.bzr', '.git', '.hg') as $vcsName) { + $finder->name($vcsName); + } + + $fs = new Filesystem(); + try { + $fs->remove($finder); + } catch (IOException $e) { + $io->write("An error occured while removing the .git directory", true); + } + } } protected function createDownloadManager(IOInterface $io, Config $config)