<commit_before><?php

namespace PHPSemVerCheckerGit\Console\Command;

use File_Iterator_Facade;
use Gitter\Client;
use PHPSemVerChecker\Reporter\Reporter;
use PHPSemVerChecker\Scanner\Scanner;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CompareCommand extends Command {
	protected function configure()
	{
		$this
			->setName('compare')
			->setDescription('Compare a set of files to determine what semantic versioning change needs to be done')
			->setDefinition([
				new InputArgument('target', InputArgument::REQUIRED, 'Directory where you git repository is located (ex my-test)'),
				new InputArgument('before', InputArgument::REQUIRED, 'A branch/tag/commit to check'),
				new InputArgument('after', InputArgument::REQUIRED, 'A branch/tag/commit to against'),
				new InputArgument('source-before', InputArgument::REQUIRED, 'A directory to check (ex my-test/src)'),
				new InputArgument('source-after', InputArgument::REQUIRED, 'A directory to check against (ex my-test/src)'),
			]);
	}

	protected function execute(InputInterface $input, OutputInterface $output)
	{
		$target = $input->getArgument('target');
		$before = $input->getArgument('before');
		$after = $input->getArgument('after');
		$beforeFiles = $input->getArgument('source-before');
		$afterFiles = $input->getArgument('source-after');

		$fileIterator = new File_Iterator_Facade;
		$beforeScanner = new Scanner();
		$afterScanner = new Scanner();

		$client = new Client();

		$repository = $client->getRepository($target);

		$initialBranch = $repository->getCurrentBranch();

		$repository->checkout($before . ' --');

		$beforeFiles = $fileIterator->getFilesAsArray($beforeFiles, '.php');
		$progress = new ProgressBar($output, count($beforeFiles));
		foreach ($beforeFiles as $file) {
			$beforeScanner->scan($file);
			$progress->advance();
		}

		$progress->clear();

		$repository->checkout($after . ' --');

		$afterFiles = $fileIterator->getFilesAsArray($afterFiles, '.php');
		$progress = new ProgressBar($output, count($afterFiles));
		foreach ($afterFiles as $file) {
			$afterScanner->scan($file);
			$progress->advance();
		}

		$progress->clear();

		if ($initialBranch) {
			$repository->checkout($initialBranch);
		}

		$progress->clear();

		$beforeRegistry = $beforeScanner->getRegistry();
		$afterRegistry = $afterScanner->getRegistry();

		$reporter = new Reporter();
		$reporter->output($beforeRegistry, $afterRegistry, $output);
	}
}<commit_msg>Updated CompareCommand to work with php-semver-checker 0.5-dev.<commit_after><?php

namespace PHPSemVerCheckerGit\Console\Command;

use File_Iterator_Facade;
use Gitter\Client;
use PHPSemVerChecker\Analyzer\Analyzer;
use PHPSemVerChecker\Reporter\Reporter;
use PHPSemVerChecker\Scanner\Scanner;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Helper\ProgressBar;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CompareCommand extends Command {
	protected function configure()
	{
		$this
			->setName('compare')
			->setDescription('Compare a set of files to determine what semantic versioning change needs to be done')
			->setDefinition([
				new InputArgument('target', InputArgument::REQUIRED, 'Directory where you git repository is located (ex my-test)'),
				new InputArgument('before', InputArgument::REQUIRED, 'A branch/tag/commit to check'),
				new InputArgument('after', InputArgument::REQUIRED, 'A branch/tag/commit to against'),
				new InputArgument('source-before', InputArgument::REQUIRED, 'A directory to check (ex my-test/src)'),
				new InputArgument('source-after', InputArgument::REQUIRED, 'A directory to check against (ex my-test/src)'),
			]);
	}

	protected function execute(InputInterface $input, OutputInterface $output)
	{
		$target = $input->getArgument('target');
		$before = $input->getArgument('before');
		$after = $input->getArgument('after');
		$beforeFiles = $input->getArgument('source-before');
		$afterFiles = $input->getArgument('source-after');

		$fileIterator = new File_Iterator_Facade;
		$beforeScanner = new Scanner();
		$afterScanner = new Scanner();

		$client = new Client();

		$repository = $client->getRepository($target);

		$initialBranch = $repository->getCurrentBranch();

		$repository->checkout($before . ' --');

		$beforeFiles = $fileIterator->getFilesAsArray($beforeFiles, '.php');
		$progress = new ProgressBar($output, count($beforeFiles));
		foreach ($beforeFiles as $file) {
			$beforeScanner->scan($file);
			$progress->advance();
		}

		$progress->clear();

		$repository->checkout($after . ' --');

		$afterFiles = $fileIterator->getFilesAsArray($afterFiles, '.php');
		$progress = new ProgressBar($output, count($afterFiles));
		foreach ($afterFiles as $file) {
			$afterScanner->scan($file);
			$progress->advance();
		}

		$progress->clear();

		if ($initialBranch) {
			$repository->checkout($initialBranch);
		}

		$progress->clear();

		$registryBefore = $beforeScanner->getRegistry();
		$registryAfter = $afterScanner->getRegistry();

		$analyzer = new Analyzer();
		$report = $analyzer->analyze($registryBefore, $registryAfter);


		$reporter = new Reporter($report);
		$reporter->output($output);
	}
}
{'fraction_non_alphanumeric': 0.15119460149553166, 'fraction_numerical': 0.0003647638154295094, 'mean_word_length': 5.474616292798111, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 54, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7389283', 'n_tokens_mistral': 1763, 'n_tokens_neox': 1617, 'n_words': 346}