Create-project command remove all VCS history
In fact, there are some issues with create-project command. When people create project with composer, they do not think to delete main .git folder. So they embed 3th history in theirs own repository. (see https://connect.sensiolabs.com/profile/jmoati/project/gitoliteadmin for instance) More over, people may not use git.pull/1213/head
parent
0175ba973c
commit
6f9c3427b6
|
@ -27,7 +27,8 @@
|
||||||
"seld/jsonlint": "1.*",
|
"seld/jsonlint": "1.*",
|
||||||
"symfony/console": "2.1.*",
|
"symfony/console": "2.1.*",
|
||||||
"symfony/finder": "2.1.*",
|
"symfony/finder": "2.1.*",
|
||||||
"symfony/process": "2.1.*"
|
"symfony/process": "2.1.*",
|
||||||
|
"symfony/filesystem": "2.1.*"
|
||||||
},
|
},
|
||||||
"suggest": {
|
"suggest": {
|
||||||
"ext-zip": "Enabling the zip extension allows you to unzip archives, and allows gzip compression of all internet traffic",
|
"ext-zip": "Enabling the zip extension allows you to unzip archives, and allows gzip compression of all internet traffic",
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"hash": "1023850095295cc1307c2219a0382930",
|
"hash": "f9e033da0cd0bd8d9fdb2e5999a7b20e",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
"name": "justinrainbow/json-schema",
|
"name": "justinrainbow/json-schema",
|
||||||
|
@ -103,6 +103,53 @@
|
||||||
"description": "Symfony Console Component",
|
"description": "Symfony Console Component",
|
||||||
"homepage": "http://symfony.com"
|
"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",
|
"name": "symfony/finder",
|
||||||
"version": "v2.1.1",
|
"version": "v2.1.1",
|
||||||
|
|
|
@ -26,6 +26,8 @@ use Symfony\Component\Console\Input\InputArgument;
|
||||||
use Symfony\Component\Console\Input\InputInterface;
|
use Symfony\Component\Console\Input\InputInterface;
|
||||||
use Symfony\Component\Console\Input\InputOption;
|
use Symfony\Component\Console\Input\InputOption;
|
||||||
use Symfony\Component\Console\Output\OutputInterface;
|
use Symfony\Component\Console\Output\OutputInterface;
|
||||||
|
use Symfony\Component\Filesystem\Filesystem;
|
||||||
|
use Symfony\Component\Finder\Finder;
|
||||||
use Composer\Json\JsonFile;
|
use Composer\Json\JsonFile;
|
||||||
use Composer\Util\RemoteFilesystem;
|
use Composer\Util\RemoteFilesystem;
|
||||||
use Composer\Package\Version\VersionParser;
|
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('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('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-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(<<<EOT
|
->setHelp(<<<EOT
|
||||||
The <info>create-project</info> command creates a new project from a given
|
The <info>create-project</info> command creates a new project from a given
|
||||||
|
@ -84,11 +87,12 @@ EOT
|
||||||
$input->getOption('dev'),
|
$input->getOption('dev'),
|
||||||
$input->getOption('repository-url'),
|
$input->getOption('repository-url'),
|
||||||
$input->getOption('no-custom-installers'),
|
$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();
|
$config = Factory::createConfig();
|
||||||
|
|
||||||
|
@ -183,6 +187,25 @@ EOT
|
||||||
}
|
}
|
||||||
|
|
||||||
$installer->run();
|
$installer->run();
|
||||||
|
|
||||||
|
if (!$keepVcs && (
|
||||||
|
!$io->isInteractive() ||
|
||||||
|
$io->askConfirmation('<info>Do you want remove all previous VCS history ?</info> [<comment>yes</comment>]: ', 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("<error>An error occured while removing the .git directory</error>", true);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function createDownloadManager(IOInterface $io, Config $config)
|
protected function createDownloadManager(IOInterface $io, Config $config)
|
||||||
|
|
Loading…
Reference in New Issue