Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

commit:validate command #906

Open
wants to merge 16 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions resources/hooks/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env sh

if [ ! -f "$APPLICATION_EXECUTABLE" ]; then #check if the cli is installed
exit 0
fi

get_git_head() {
if git rev-parse --verify HEAD >/dev/null 2>&1
then
echo "HEAD"
else
git hash-object -t tree /dev/null
fi
}

against=$(get_git_head)

exec < /dev/tty #redirect keyboard input so we can do interactivity in symfony
$APPLICATION_EXECUTABLE commit:validate $against 1>/dev/null

if [ $? -eq 0 ]
then
echo "CLI says OK, allow commit."
exit 0
else
echo "Cancelling commit."
exit 1
fi
exec <&- #restore keyboard input
1 change: 1 addition & 0 deletions src/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ protected function getCommands()
$commands[] = new Command\Certificate\CertificateListCommand();
$commands[] = new Command\Commit\CommitGetCommand();
$commands[] = new Command\Commit\CommitListCommand();
$commands[] = new Command\Commit\CommitValidateCommand();
$commands[] = new Command\Db\DbSqlCommand();
$commands[] = new Command\Db\DbDumpCommand();
$commands[] = new Command\Db\DbSizeCommand();
Expand Down
9 changes: 8 additions & 1 deletion src/Command/App/AppConfigGetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
use Platformsh\Cli\Command\CommandBase;
use Platformsh\Cli\Model\AppConfig;
use Platformsh\Cli\Model\Host\LocalHost;
use Platformsh\Cli\Local\LocalApplication;

use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -19,7 +21,8 @@ protected function configure()
->setName('app:config-get')
->setDescription('View the configuration of an app')
->addOption('property', 'P', InputOption::VALUE_REQUIRED, 'The configuration property to view')
->addOption('refresh', null, InputOption::VALUE_NONE, 'Whether to refresh the cache');
->addOption('refresh', null, InputOption::VALUE_NONE, 'Whether to refresh the cache')
->addOption('local','L', InputOption::VALUE_NONE, 'Use the local configuration');
$this->addProjectOption();
$this->addEnvironmentOption();
$this->addAppOption();
Expand All @@ -31,6 +34,7 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{

// Allow override via PLATFORM_APPLICATION.
$prefix = $this->config()->get('service.env_prefix');
if (getenv($prefix . 'APPLICATION') && !LocalHost::conflictsWithCommandLineOptions($input, $prefix)) {
Expand All @@ -40,6 +44,9 @@ protected function execute(InputInterface $input, OutputInterface $output)
throw new \RuntimeException('Failed to decode: ' . $prefix . 'APPLICATION');
}
$appConfig = new AppConfig($decoded);
} elseif((bool) $input->getOption('local')) {
$local = new LocalApplication($this->getProjectRoot());
$appConfig = new AppConfig($local->getConfig());
} else {
$this->validateInput($input);
$this->warnAboutDeprecatedOptions(['identity-file']);
Expand Down
Loading