<commit_before><?php
namespace Bart\Git_Hook;
use Bart\Gerrit\Change;
use Bart\Gerrit\GerritException;
use Bart\Git_Exception;

/**
 * Abandon Gerrit review
 */
class GerritAbandon extends GitHookAction
{
	/**
	 * Run the hook
	 * @param string $commitHash Commit with Gerrit Change-Id
	 * @throws GitHookException if requirement fails
	 */
	public function run($commitHash)
	{
		try {
			$changeId = $this->git->get_change_id($commitHash);
		}
		catch (Git_Exception $e) {
			$this->logger->warn("{$e->getMessage()}. Skipping commit.");
			return;
		}

		$change = new Change($changeId);

		try {
			if (!$change->exists()) {
				// This is not a warning, because some repositories do not require code review
				$this->logger->debug('Skipping change b/c it does not exist in Gerrit');
				return;
			}

			$change->abandon('Abandoning from git hook.');
		}
		catch (GerritException $e) {
			$this->logger->error('Problem abandoning change. Ignoring and moving on with hook.', $e);
		}
	}
}<commit_msg>A change missing in gerrit is INFO level interesting<commit_after><?php
namespace Bart\Git_Hook;
use Bart\Gerrit\Change;
use Bart\Gerrit\GerritException;
use Bart\Git_Exception;

/**
 * Abandon Gerrit review
 */
class GerritAbandon extends GitHookAction
{
	/**
	 * Run the hook
	 * @param string $commitHash Commit with Gerrit Change-Id
	 * @throws GitHookException if requirement fails
	 */
	public function run($commitHash)
	{
		try {
			$changeId = $this->git->get_change_id($commitHash);
		}
		catch (Git_Exception $e) {
			$this->logger->warn("{$e->getMessage()}. Skipping commit.");
			return;
		}

		$change = new Change($changeId);

		try {
			if (!$change->exists()) {
				// This is not a warning, because some repositories do not require code review
				$this->logger->info('Skipping change b/c it does not exist in Gerrit');
				return;
			}

			$change->abandon("Abandoning from git hook for commit {$commitHash}.");
		}
		catch (GerritException $e) {
			$this->logger->error('Problem abandoning change. Ignoring and moving on with hook.', $e);
		}
	}
}
{'fraction_non_alphanumeric': 0.13581440309328177, 'fraction_numerical': 0.0, 'mean_word_length': 3.7260273972602738, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '4608091', 'n_tokens_mistral': 751, 'n_tokens_neox': 651, 'n_words': 191}