@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | parent::configure(); |
| 39 | 39 | $this->setName('config:enable') |
| 40 | - ->setAliases(['enable']) |
|
| 41 | - ->setDescription('Enable the handling for a hook in your configuration') |
|
| 42 | - ->setHelp('Enable the handling for a hook in your configuration') |
|
| 43 | - ->addArgument('hook', InputArgument::REQUIRED, 'Hook you want to enable'); |
|
| 40 | + ->setAliases(['enable']) |
|
| 41 | + ->setDescription('Enable the handling for a hook in your configuration') |
|
| 42 | + ->setHelp('Enable the handling for a hook in your configuration') |
|
| 43 | + ->addArgument('hook', InputArgument::REQUIRED, 'Hook you want to enable'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $editor = new Editor($io, $config); |
| 64 | 64 | $editor->setHook(IOUtil::argToString($input->getArgument('hook'))) |
| 65 | - ->setChange('EnableHook') |
|
| 66 | - ->run(); |
|
| 65 | + ->setChange('EnableHook') |
|
| 66 | + ->run(); |
|
| 67 | 67 | |
| 68 | 68 | return 0; |
| 69 | 69 | } catch (Exception $e) { |
@@ -37,10 +37,10 @@ discard block |
||
| 37 | 37 | { |
| 38 | 38 | parent::configure(); |
| 39 | 39 | $this->setName('config:disable') |
| 40 | - ->setAliases(['disable']) |
|
| 41 | - ->setDescription('Disable the handling for a hook in your configuration') |
|
| 42 | - ->setHelp('Disable the handling for a hook in your configuration') |
|
| 43 | - ->addArgument('hook', InputArgument::REQUIRED, 'Hook you want to disable'); |
|
| 40 | + ->setAliases(['disable']) |
|
| 41 | + ->setDescription('Disable the handling for a hook in your configuration') |
|
| 42 | + ->setHelp('Disable the handling for a hook in your configuration') |
|
| 43 | + ->addArgument('hook', InputArgument::REQUIRED, 'Hook you want to disable'); |
|
| 44 | 44 | } |
| 45 | 45 | |
| 46 | 46 | /** |
@@ -62,8 +62,8 @@ discard block |
||
| 62 | 62 | |
| 63 | 63 | $editor = new Editor($io, $config); |
| 64 | 64 | $editor->setHook(IOUtil::argToString($input->getArgument('hook'))) |
| 65 | - ->setChange('DisableHook') |
|
| 66 | - ->run(); |
|
| 65 | + ->setChange('DisableHook') |
|
| 66 | + ->run(); |
|
| 67 | 67 | |
| 68 | 68 | return 0; |
| 69 | 69 | } catch (Exception $e) { |
@@ -42,64 +42,64 @@ discard block |
||
| 42 | 42 | { |
| 43 | 43 | parent::configure(); |
| 44 | 44 | $this->setName('install') |
| 45 | - ->setDescription('Install hooks to your .git/hooks directory') |
|
| 46 | - ->setHelp('Install git hooks to your .git/hooks directory') |
|
| 47 | - ->addArgument( |
|
| 48 | - 'hook', |
|
| 49 | - InputArgument::OPTIONAL, |
|
| 50 | - 'Limit the hooks you want to install. ' . |
|
| 51 | - 'You can specify multiple hooks with comma as delimiter. ' . |
|
| 52 | - 'By default all hooks get installed' |
|
| 53 | - ) |
|
| 54 | - ->addOption( |
|
| 55 | - 'only-enabled', |
|
| 56 | - null, |
|
| 57 | - InputOption::VALUE_NONE, |
|
| 58 | - 'Limit the hooks you want to install to those enabled in your conf. ' . |
|
| 59 | - 'By default all hooks get installed' |
|
| 60 | - ) |
|
| 61 | - ->addOption( |
|
| 62 | - 'force', |
|
| 63 | - 'f', |
|
| 64 | - InputOption::VALUE_NONE, |
|
| 65 | - 'Force install without confirmation' |
|
| 66 | - ) |
|
| 67 | - ->addOption( |
|
| 68 | - 'skip-existing', |
|
| 69 | - 's', |
|
| 70 | - InputOption::VALUE_NONE, |
|
| 71 | - 'Do not overwrite existing hooks' |
|
| 72 | - ) |
|
| 73 | - ->addOption( |
|
| 74 | - 'move-existing-to', |
|
| 75 | - null, |
|
| 76 | - InputOption::VALUE_OPTIONAL, |
|
| 77 | - 'Move existing hooks to given directory' |
|
| 78 | - ) |
|
| 79 | - ->addOption( |
|
| 80 | - 'bootstrap', |
|
| 81 | - 'b', |
|
| 82 | - InputOption::VALUE_OPTIONAL, |
|
| 83 | - 'Path to composers vendor/autoload.php' |
|
| 84 | - ) |
|
| 85 | - ->addOption( |
|
| 86 | - 'run-mode', |
|
| 87 | - 'm', |
|
| 88 | - InputOption::VALUE_OPTIONAL, |
|
| 89 | - 'Git hook run mode [php|shell|docker]' |
|
| 90 | - ) |
|
| 91 | - ->addOption( |
|
| 92 | - 'run-exec', |
|
| 93 | - 'e', |
|
| 94 | - InputOption::VALUE_OPTIONAL, |
|
| 95 | - 'The Docker command to start your container e.g. \'docker exec CONTAINER\'' |
|
| 96 | - ) |
|
| 97 | - ->addOption( |
|
| 98 | - 'run-path', |
|
| 99 | - 'p', |
|
| 100 | - InputOption::VALUE_OPTIONAL, |
|
| 101 | - 'The path to the CaptainHook executable \'/usr/bin/captainhook\'' |
|
| 102 | - ); |
|
| 45 | + ->setDescription('Install hooks to your .git/hooks directory') |
|
| 46 | + ->setHelp('Install git hooks to your .git/hooks directory') |
|
| 47 | + ->addArgument( |
|
| 48 | + 'hook', |
|
| 49 | + InputArgument::OPTIONAL, |
|
| 50 | + 'Limit the hooks you want to install. ' . |
|
| 51 | + 'You can specify multiple hooks with comma as delimiter. ' . |
|
| 52 | + 'By default all hooks get installed' |
|
| 53 | + ) |
|
| 54 | + ->addOption( |
|
| 55 | + 'only-enabled', |
|
| 56 | + null, |
|
| 57 | + InputOption::VALUE_NONE, |
|
| 58 | + 'Limit the hooks you want to install to those enabled in your conf. ' . |
|
| 59 | + 'By default all hooks get installed' |
|
| 60 | + ) |
|
| 61 | + ->addOption( |
|
| 62 | + 'force', |
|
| 63 | + 'f', |
|
| 64 | + InputOption::VALUE_NONE, |
|
| 65 | + 'Force install without confirmation' |
|
| 66 | + ) |
|
| 67 | + ->addOption( |
|
| 68 | + 'skip-existing', |
|
| 69 | + 's', |
|
| 70 | + InputOption::VALUE_NONE, |
|
| 71 | + 'Do not overwrite existing hooks' |
|
| 72 | + ) |
|
| 73 | + ->addOption( |
|
| 74 | + 'move-existing-to', |
|
| 75 | + null, |
|
| 76 | + InputOption::VALUE_OPTIONAL, |
|
| 77 | + 'Move existing hooks to given directory' |
|
| 78 | + ) |
|
| 79 | + ->addOption( |
|
| 80 | + 'bootstrap', |
|
| 81 | + 'b', |
|
| 82 | + InputOption::VALUE_OPTIONAL, |
|
| 83 | + 'Path to composers vendor/autoload.php' |
|
| 84 | + ) |
|
| 85 | + ->addOption( |
|
| 86 | + 'run-mode', |
|
| 87 | + 'm', |
|
| 88 | + InputOption::VALUE_OPTIONAL, |
|
| 89 | + 'Git hook run mode [php|shell|docker]' |
|
| 90 | + ) |
|
| 91 | + ->addOption( |
|
| 92 | + 'run-exec', |
|
| 93 | + 'e', |
|
| 94 | + InputOption::VALUE_OPTIONAL, |
|
| 95 | + 'The Docker command to start your container e.g. \'docker exec CONTAINER\'' |
|
| 96 | + ) |
|
| 97 | + ->addOption( |
|
| 98 | + 'run-path', |
|
| 99 | + 'p', |
|
| 100 | + InputOption::VALUE_OPTIONAL, |
|
| 101 | + 'The path to the CaptainHook executable \'/usr/bin/captainhook\'' |
|
| 102 | + ); |
|
| 103 | 103 | } |
| 104 | 104 | |
| 105 | 105 | /** |
@@ -123,11 +123,11 @@ discard block |
||
| 123 | 123 | |
| 124 | 124 | $installer = new Installer($io, $config, $repo, $template); |
| 125 | 125 | $installer->setHook(IOUtil::argToString($input->getArgument('hook'))) |
| 126 | - ->setForce(IOUtil::argToBool($input->getOption('force'))) |
|
| 127 | - ->setSkipExisting(IOUtil::argToBool($input->getOption('skip-existing'))) |
|
| 128 | - ->setMoveExistingTo(IOUtil::argToString($input->getOption('move-existing-to'))) |
|
| 129 | - ->setOnlyEnabled(IOUtil::argToBool($input->getOption('only-enabled'))) |
|
| 130 | - ->run(); |
|
| 126 | + ->setForce(IOUtil::argToBool($input->getOption('force'))) |
|
| 127 | + ->setSkipExisting(IOUtil::argToBool($input->getOption('skip-existing'))) |
|
| 128 | + ->setMoveExistingTo(IOUtil::argToString($input->getOption('move-existing-to'))) |
|
| 129 | + ->setOnlyEnabled(IOUtil::argToBool($input->getOption('only-enabled'))) |
|
| 130 | + ->run(); |
|
| 131 | 131 | |
| 132 | 132 | return 0; |
| 133 | 133 | } catch (Exception $e) { |
@@ -38,17 +38,17 @@ discard block |
||
| 38 | 38 | { |
| 39 | 39 | parent::configure(); |
| 40 | 40 | $this->setName('configure') |
| 41 | - ->setDescription('Create or update a captainhook.json configuration') |
|
| 42 | - ->setHelp('Create or update a captainhook.json configuration') |
|
| 43 | - ->addOption('extend', 'e', InputOption::VALUE_NONE, 'Extend existing configuration file') |
|
| 44 | - ->addOption('force', 'f', InputOption::VALUE_NONE, 'Overwrite existing configuration file') |
|
| 45 | - ->addOption('advanced', 'a', InputOption::VALUE_NONE, 'More options, but more to type') |
|
| 46 | - ->addOption( |
|
| 47 | - 'bootstrap', |
|
| 48 | - null, |
|
| 49 | - InputOption::VALUE_OPTIONAL, |
|
| 50 | - 'Path to composers vendor/autoload.php' |
|
| 51 | - ); |
|
| 41 | + ->setDescription('Create or update a captainhook.json configuration') |
|
| 42 | + ->setHelp('Create or update a captainhook.json configuration') |
|
| 43 | + ->addOption('extend', 'e', InputOption::VALUE_NONE, 'Extend existing configuration file') |
|
| 44 | + ->addOption('force', 'f', InputOption::VALUE_NONE, 'Overwrite existing configuration file') |
|
| 45 | + ->addOption('advanced', 'a', InputOption::VALUE_NONE, 'More options, but more to type') |
|
| 46 | + ->addOption( |
|
| 47 | + 'bootstrap', |
|
| 48 | + null, |
|
| 49 | + InputOption::VALUE_OPTIONAL, |
|
| 50 | + 'Path to composers vendor/autoload.php' |
|
| 51 | + ); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -69,10 +69,10 @@ discard block |
||
| 69 | 69 | |
| 70 | 70 | $configurator = new Creator($io, $config); |
| 71 | 71 | $configurator->force(IOUtil::argToBool($input->getOption('force'))) |
| 72 | - ->extend(IOUtil::argToBool($input->getOption('extend'))) |
|
| 73 | - ->advanced(IOUtil::argToBool($input->getOption('advanced'))) |
|
| 74 | - ->setExecutable($this->resolver->getExecutable()) |
|
| 75 | - ->run(); |
|
| 72 | + ->extend(IOUtil::argToBool($input->getOption('extend'))) |
|
| 73 | + ->advanced(IOUtil::argToBool($input->getOption('advanced'))) |
|
| 74 | + ->setExecutable($this->resolver->getExecutable()) |
|
| 75 | + ->run(); |
|
| 76 | 76 | |
| 77 | 77 | return 0; |
| 78 | 78 | } catch (Exception $e) { |
@@ -46,8 +46,8 @@ discard block |
||
| 46 | 46 | ->method('getBranchRevFromRefLog') |
| 47 | 47 | ->willReturn('main'); |
| 48 | 48 | $info->expects($this->once()) |
| 49 | - ->method('getCurrentBranch') |
|
| 50 | - ->willReturn('foo'); |
|
| 49 | + ->method('getCurrentBranch') |
|
| 50 | + ->willReturn('foo'); |
|
| 51 | 51 | |
| 52 | 52 | $repo->expects($this->atLeastOnce())->method('getLogOperator')->willReturn($log); |
| 53 | 53 | $repo->expects($this->atLeastOnce())->method('getDiffOperator')->willReturn($diff); |
@@ -98,8 +98,8 @@ discard block |
||
| 98 | 98 | $diff = $this->createGitDiffOperator(['file1.php', 'file2.php', 'README.md', 'foo.txt']); |
| 99 | 99 | |
| 100 | 100 | $info->expects($this->once()) |
| 101 | - ->method('getCurrentBranch') |
|
| 102 | - ->willReturn('foo'); |
|
| 101 | + ->method('getCurrentBranch') |
|
| 102 | + ->willReturn('foo'); |
|
| 103 | 103 | |
| 104 | 104 | $repo->expects($this->atLeastOnce())->method('getDiffOperator')->willReturn($diff); |
| 105 | 105 | $repo->expects($this->atLeastOnce())->method('getInfoOperator')->willReturn($info); |
@@ -122,8 +122,8 @@ discard block |
||
| 122 | 122 | $diff = $this->createGitDiffOperator(['foo/file1.php', 'foo/file2.php', 'README.md', 'foo.txt']); |
| 123 | 123 | |
| 124 | 124 | $info->expects($this->once()) |
| 125 | - ->method('getCurrentBranch') |
|
| 126 | - ->willReturn('foo'); |
|
| 125 | + ->method('getCurrentBranch') |
|
| 126 | + ->willReturn('foo'); |
|
| 127 | 127 | |
| 128 | 128 | $repo->expects($this->atLeastOnce())->method('getDiffOperator')->willReturn($diff); |
| 129 | 129 | $repo->expects($this->atLeastOnce())->method('getInfoOperator')->willReturn($info); |
@@ -56,16 +56,16 @@ |
||
| 56 | 56 | ); |
| 57 | 57 | |
| 58 | 58 | $io = $this->getMockBuilder(DefaultIO::class) |
| 59 | - ->disableOriginalConstructor() |
|
| 60 | - ->getMock(); |
|
| 59 | + ->disableOriginalConstructor() |
|
| 60 | + ->getMock(); |
|
| 61 | 61 | |
| 62 | 62 | $invokedCount = $this->atLeast(2); |
| 63 | 63 | $io->expects($invokedCount) |
| 64 | - ->method('ask') |
|
| 65 | - ->willReturnCallback(function ($parameters) use ($invokedCount) { |
|
| 66 | - $results = ['\\Foo\\Bar', 'n']; |
|
| 67 | - return $results[$invokedCount->numberOfInvocations() - 1] ?? ''; |
|
| 68 | - }); |
|
| 64 | + ->method('ask') |
|
| 65 | + ->willReturnCallback(function ($parameters) use ($invokedCount) { |
|
| 66 | + $results = ['\\Foo\\Bar', 'n']; |
|
| 67 | + return $results[$invokedCount->numberOfInvocations() - 1] ?? ''; |
|
| 68 | + }); |
|
| 69 | 69 | |
| 70 | 70 | $io->expects($this->once())->method('write'); |
| 71 | 71 | |
@@ -42,8 +42,8 @@ |
||
| 42 | 42 | $config = '/foo/bar/fiz/baz/config.json'; |
| 43 | 43 | $input = new ArrayInput(['--configuration' => $config]); |
| 44 | 44 | $output = $this->getMockBuilder(OutputInterface::class) |
| 45 | - ->disableOriginalConstructor() |
|
| 46 | - ->getMock(); |
|
| 45 | + ->disableOriginalConstructor() |
|
| 46 | + ->getMock(); |
|
| 47 | 47 | $output->method('isVerbose')->willReturn(true); |
| 48 | 48 | |
| 49 | 49 | $configure = new Configuration($resolver); |
@@ -176,8 +176,8 @@ discard block |
||
| 176 | 176 | |
| 177 | 177 | $runner = new Uninstaller($io, $config, $repo); |
| 178 | 178 | $runner->setHook('post-merge') |
| 179 | - ->setMoveExistingTo('foo/bar/') |
|
| 180 | - ->run(); |
|
| 179 | + ->setMoveExistingTo('foo/bar/') |
|
| 180 | + ->run(); |
|
| 181 | 181 | |
| 182 | 182 | $this->assertFileDoesNotExist($fakeRepo->getHookDir() . '/post-merge'); |
| 183 | 183 | $this->assertFileExists($fakeRepo->getRoot() . '/foo/bar/post-merge'); |
@@ -208,8 +208,8 @@ discard block |
||
| 208 | 208 | |
| 209 | 209 | $runner = new Uninstaller($io, $config, $repo); |
| 210 | 210 | $runner->setHook('pre-commit') |
| 211 | - ->setMoveExistingTo('foo') |
|
| 212 | - ->run(); |
|
| 211 | + ->setMoveExistingTo('foo') |
|
| 212 | + ->run(); |
|
| 213 | 213 | } |
| 214 | 214 | |
| 215 | 215 | public function testMoveExistingHookWhenMoveExistingIsAnAbsolutePath(): void |
@@ -237,8 +237,8 @@ discard block |
||
| 237 | 237 | |
| 238 | 238 | $runner = new Uninstaller($io, $config, $repo); |
| 239 | 239 | $runner->setHook('pre-commit') |
| 240 | - ->setMoveExistingTo($virtualFs->url() . '/foo/bar') |
|
| 241 | - ->run(); |
|
| 240 | + ->setMoveExistingTo($virtualFs->url() . '/foo/bar') |
|
| 241 | + ->run(); |
|
| 242 | 242 | |
| 243 | 243 | $this->assertFileDoesNotExist($fakeRepo->getHookDir() . '/pre-commit'); |
| 244 | 244 | $this->assertFileExists($fakeRepo->getRoot() . '/foo/bar/pre-commit'); |
@@ -33,8 +33,8 @@ discard block |
||
| 33 | 33 | |
| 34 | 34 | $runner = new Editor($io, $config); |
| 35 | 35 | $runner->setHook('foo') |
| 36 | - ->setChange('EnableHook') |
|
| 37 | - ->run(); |
|
| 36 | + ->setChange('EnableHook') |
|
| 37 | + ->run(); |
|
| 38 | 38 | } |
| 39 | 39 | |
| 40 | 40 | public function testNoHook(): void |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | |
| 48 | 48 | $runner = new Editor($io, $config); |
| 49 | 49 | $runner->setChange('EnableHook') |
| 50 | - ->run(); |
|
| 50 | + ->run(); |
|
| 51 | 51 | } |
| 52 | 52 | |
| 53 | 53 | public function testNoChange(): void |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | |
| 61 | 61 | $runner = new Editor($io, $config); |
| 62 | 62 | $runner->setHook('pre-commit') |
| 63 | - ->run(); |
|
| 63 | + ->run(); |
|
| 64 | 64 | } |
| 65 | 65 | |
| 66 | 66 | public function testInvalidChange(): void |
@@ -73,8 +73,8 @@ discard block |
||
| 73 | 73 | |
| 74 | 74 | $runner = new Editor($io, $config); |
| 75 | 75 | $runner->setChange('InvalidChange') |
| 76 | - ->setHook('pre-commit') |
|
| 77 | - ->run(); |
|
| 76 | + ->setHook('pre-commit') |
|
| 77 | + ->run(); |
|
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 80 | public function testMissingHook(): void |
@@ -87,7 +87,7 @@ discard block |
||
| 87 | 87 | |
| 88 | 88 | $runner = new Editor($io, $config); |
| 89 | 89 | $runner->setChange('EnableHook') |
| 90 | - ->run(); |
|
| 90 | + ->run(); |
|
| 91 | 91 | } |
| 92 | 92 | |
| 93 | 93 | public function testMissingChange(): void |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | |
| 101 | 101 | $runner = new Editor($io, $config); |
| 102 | 102 | $runner->setHook('pre-commit') |
| 103 | - ->run(); |
|
| 103 | + ->run(); |
|
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function testNoConfiguration() |
@@ -113,8 +113,8 @@ discard block |
||
| 113 | 113 | |
| 114 | 114 | $runner = new Editor($io, $config); |
| 115 | 115 | $runner->setChange('AddAction') |
| 116 | - ->setHook('pre-commit') |
|
| 117 | - ->run(); |
|
| 116 | + ->setHook('pre-commit') |
|
| 117 | + ->run(); |
|
| 118 | 118 | } |
| 119 | 119 | |
| 120 | 120 | public function testConfigureFileExtend() |
@@ -125,17 +125,17 @@ discard block |
||
| 125 | 125 | $config = $this->createConfigMock(true, $configDir->url() . '/captainhook.json'); |
| 126 | 126 | $config->method('getHookConfig')->willReturn($this->createHookConfigMock()); |
| 127 | 127 | $io->expects($invocations) |
| 128 | - ->method('ask') |
|
| 129 | - ->willReturnCallback(function ($parameters) use ($invocations) { |
|
| 130 | - $results = ['y', 'y', '\\Foo\\Bar', 'y', 'foo:bar', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n']; |
|
| 131 | - return $results[$invocations->numberOfInvocations() - 1] ?? ''; |
|
| 132 | - }); |
|
| 128 | + ->method('ask') |
|
| 129 | + ->willReturnCallback(function ($parameters) use ($invocations) { |
|
| 130 | + $results = ['y', 'y', '\\Foo\\Bar', 'y', 'foo:bar', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n', 'n']; |
|
| 131 | + return $results[$invocations->numberOfInvocations() - 1] ?? ''; |
|
| 132 | + }); |
|
| 133 | 133 | $io->expects($this->once())->method('askAndValidate')->willReturn('foo:bar'); |
| 134 | 134 | |
| 135 | 135 | $runner = new Creator($io, $config); |
| 136 | 136 | $runner->extend(true) |
| 137 | - ->advanced(true) |
|
| 138 | - ->run(); |
|
| 137 | + ->advanced(true) |
|
| 138 | + ->run(); |
|
| 139 | 139 | |
| 140 | 140 | $this->assertFileExists($configDir->url() . '/captainhook.json'); |
| 141 | 141 | } |