<commit_before><?php
/**
 * Golem_Cli_Command_Flow
 * Git-flow shortcuts
 *
 * @author       <NAME> | grrr.nl
 * @version      0.0.1
 * @package      Golem_Cli_Command
 */
class Golem_Cli_Command_Flow extends Golem_Cli_Command {

	/**
 	 * Overwrite to perform sanity checks
 	 */
	public function main(array $args = array()) {
		// Sanity check: do you have the right tools for the job?
		if (!$this->_required_tools_available()) {
			return false;
		}

		// Validate wether the git index is clean
		if (!$this->_validate_status()) {
			return false;
		}		


		return parent::main($args);
	}

	/**
 	 * Start a new release branch
 	 */
	public function startRelease(array $args = array()) {
		// Can be minor, major, or 'special'
		$type = isset($args[0]) ? $args[0] : 'minor';
		$this->_bump_version($type);
		$version = $this->_get_current_version();

		// Stash cause we can't start the release until the git index is clean
		$git_stash_cmd = 'git stash';
		$this->_exec_cmd($git_stash_cmd);

		$git_flow_start_release_cmd = 'git flow release start ' . $version;
		$this->_exec_cmd($git_flow_start_release_cmd);

		$git_stash_pop_cmd = 'git stash pop';
		$this->_exec_cmd($git_stash_pop_cmd);

		$git_add_cmd = 'git add .semver';
		$this->_exec_cmd($git_add_cmd);

		// Commit semver
		$git_ci_cmd  = 'git commit -m "Incremented version to ' . $version . '."';
		$this->_exec_cmd($git_ci_cmd);
		return true;
	}

	/**
 	 * Finish current git flow release
 	 */
	public function finishRelease() {
		$version = $this->_get_current_version();
		if (!$this->_validate_branch('release', $version)) {
			return false;
		}
		$git_flow_finish_release_cmd = 'git flow release finish -m "Release_' . $version . '" ' . $version;
		passthru($git_flow_finish_release_cmd);
		return true;
	}

	/**
 	 * Start hotfix branch
 	 */
	public function startHotfix(array $args = array()) {
		$this->_bump_version('patch');
		$version = $this->_get_current_version();
		// Reset version cause we want to submit it only when finishing the hotfix
		$git_co_cmd = 'git checkout -- .semver';
		$this->_exec_cmd($git_co_cmd);

		$git_flow_start_release_cmd = 'git flow hotfix -F start ' . $version;
		$this->_exec_cmd($git_flow_start_release_cmd);
		return true;
	}

	/**
 	 * Finish hotfix branch
 	 */
	public function finishHotfix(array $args = array()) {
		$this->_bump_version('patch');
		$version = $this->_get_current_version();
		if (!$this->_validate_branch('hotfix', $version)) {
			// When shit hits the fan: revert semver
			$git_co_cmd = 'git checkout -- .semver';
			$this->_exec_cmd($git_co_cmd);
			return false;
		}

		$git_add_cmd = 'git add .semver';
		$this->_exec_cmd($git_add_cmd);

		// Commit semver
		$git_ci_cmd  = 'git commit -m "Incremented version to ' . $version . '."';<commit_msg>Reverted -F flag: does not work<commit_after><?php
/**
 * Golem_Cli_Command_Flow
 * Git-flow shortcuts
 *
 * @author       <NAME> | grrr.nl
 * @version      0.0.1
 * @package      Golem_Cli_Command
 */
class Golem_Cli_Command_Flow extends Golem_Cli_Command {

	/**
 	 * Overwrite to perform sanity checks
 	 */
	public function main(array $args = array()) {
		// Sanity check: do you have the right tools for the job?
		if (!$this->_required_tools_available()) {
			return false;
		}

		// Validate wether the git index is clean
		if (!$this->_validate_status()) {
			return false;
		}		


		return parent::main($args);
	}

	/**
 	 * Start a new release branch
 	 */
	public function startRelease(array $args = array()) {
		// Can be minor, major, or 'special'
		$type = isset($args[0]) ? $args[0] : 'minor';
		$this->_bump_version($type);
		$version = $this->_get_current_version();

		// Stash cause we can't start the release until the git index is clean
		$git_stash_cmd = 'git stash';
		$this->_exec_cmd($git_stash_cmd);

		$git_flow_start_release_cmd = 'git flow release start ' . $version;
		$this->_exec_cmd($git_flow_start_release_cmd);

		$git_stash_pop_cmd = 'git stash pop';
		$this->_exec_cmd($git_stash_pop_cmd);

		$git_add_cmd = 'git add .semver';
		$this->_exec_cmd($git_add_cmd);

		// Commit semver
		$git_ci_cmd  = 'git commit -m "Incremented version to ' . $version . '."';
		$this->_exec_cmd($git_ci_cmd);
		return true;
	}

	/**
 	 * Finish current git flow release
 	 */
	public function finishRelease() {
		$version = $this->_get_current_version();
		if (!$this->_validate_branch('release', $version)) {
			return false;
		}
		$git_flow_finish_release_cmd = 'git flow release finish -m "Release_' . $version . '" ' . $version;
		passthru($git_flow_finish_release_cmd);
		return true;
	}

	/**
 	 * Start hotfix branch
 	 */
	public function startHotfix(array $args = array()) {
		$this->_bump_version('patch');
		$version = $this->_get_current_version();
		// Reset version cause we want to submit it only when finishing the hotfix
		$git_co_cmd = 'git checkout -- .semver';
		$this->_exec_cmd($git_co_cmd);

		$git_flow_start_release_cmd = 'git flow hotfix start ' . $version;
		$this->_exec_cmd($git_flow_start_release_cmd);
		return true;
	}

	/**
 	 * Finish hotfix branch
 	 */
	public function finishHotfix(array $args = array()) {
		$this->_bump_version('patch');
		$version = $this->_get_current_version();
		if (!$this->_validate_branch('hotfix', $version)) {
			// When shit hits the fan: revert semver
			$git_co_cmd = 'git checkout -- .semver';
			$this->_exec_cmd($git_co_cmd);
			return false;
		}

		$git_add_cmd = 'git add .semver';
		$this->_exec_cmd($git_add_cmd);

		// Commit semver
		$git_ci_cmd  = 'git commit -m "Incremented version to ' . $version . '."';
{'fraction_non_alphanumeric': 0.14679063114607546, 'fraction_numerical': 0.0017879492222420883, 'mean_word_length': 3.665554628857381, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 45, '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': 2, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '228234', 'n_tokens_mistral': 2138, 'n_tokens_neox': 1953, 'n_words': 468}