<commit_before><?php

/**
 * A phing task to load modules from a specific URL via SVN checkouts
 *
 * Passes commands directly to the commandline to actually perform the
 * svn checkout/updates, so you must have these on your path when this
 * runs.
 *
 * @author <NAME> <<EMAIL>>
 *
 */
class LoadModulesTask extends Task
{
	/**
	 * The file that defines the dependency
	 *
	 * @var String
	 */
	private $file = '';

	/**
	 * Optionally specify a module name
	 *
	 * @var String
	 */
	private $name = '';

	/**
	 * And a module url
	 * @var String
	 */
	private $url = '';

	public function setFile($v)
	{
		$this->file = $v;
	}

	public function setName($v)
	{
		$this->name = $v;
	}

	public function setUrl($v)
	{
		$this->url = $v;
	}


	public function main()
	{
		if ($this->name) {
			$this->loadModule($this->name, $this->url);
		} else {
			// load the items from the dependencies file
			if (!file_exists($this->file)) {
				throw new BuildException("Modules file ".$this->modulesFile." cannot be read");
			}

			$items = file($this->file);
			foreach ($items as $item) {
				$item = trim($item);
				if (strpos($item, '#') === 0) {
					continue;
				}
				$bits = preg_split('/\s+/', $item);
				// skip malformed lines
				if (count($bits) < 2) {
					continue;
				}

				$moduleName = trim($bits[0], '/');
				$svnUrl = trim($bits[1], '/');
				$devBuild = isset($bits[2]) ? $bits[2] != 'false' : true;

				$this->loadModule($moduleName, $svnUrl, $devBuild);
			}
		}
	}

	/**
	 * Actually load the module!
	 *
	 * @param String $moduleName
	 * @param String $svnUrl
	 * @param boolean $devBuild
	 * 			Do we run a dev/build?
	 */
	protected function loadModule($moduleName, $svnUrl, $devBuild = true)
	{
		$git = strrpos($svnUrl, '.git') == (strlen($svnUrl) - 4);

		// check the module out if it doesn't exist
		if (!file_exists($moduleName)) {
			echo "Check out $moduleName from $svnUrl\n";
			// check whether it's git or svn
			if ($git) {
				echo `git clone $svnUrl $moduleName`;
			} else {
				echo `svn co $svnUrl $moduleName`;
			}

		} else {
			echo "Updating $moduleName from $svnUrl\n";
			if ($git) {
				echo `cd $moduleName && git pull origin && cd ..`;
			} else {
				echo `svn up $moduleName`;
			}
		}

		if ($devBuild && file_exists('sapphire/cli-script.php')) {
			echo "Running dev/build\n";
			exec('php sapphire/cli-script.php dev/build', $output, $result);
		}
	}
}

?><commit_msg>MINOR: Add modules to .gitignore<commit_after><?php

/**
 * A phing task to load modules from a specific URL via SVN checkouts
 *
 * Passes commands directly to the commandline to actually perform the
 * svn checkout/updates, so you must have these on your path when this
 * runs.
 *
 * @author <NAME> <<EMAIL>>
 *
 */
class LoadModulesTask extends Task
{
	/**
	 * The file that defines the dependency
	 *
	 * @var String
	 */
	private $file = '';

	/**
	 * Optionally specify a module name
	 *
	 * @var String
	 */
	private $name = '';

	/**
	 * And a module url
	 * @var String
	 */
	private $url = '';

	public function setFile($v)
	{
		$this->file = $v;
	}

	public function setName($v)
	{
		$this->name = $v;
	}

	public function setUrl($v)
	{
		$this->url = $v;
	}


	public function main()
	{
		if ($this->name) {
			$this->loadModule($this->name, $this->url);
		} else {
			// load the items from the dependencies file
			if (!file_exists($this->file)) {
				throw new BuildException("Modules file ".$this->modulesFile." cannot be read");
			}

			$items = file($this->file);
			foreach ($items as $item) {
				$item = trim($item);
				if (strpos($item, '#') === 0) {
					continue;
				}
				$bits = preg_split('/\s+/', $item);
				// skip malformed lines
				if (count($bits) < 2) {
					continue;
				}

				$moduleName = trim($bits[0], '/');
				$svnUrl = trim($bits[1], '/');
				$devBuild = isset($bits[2]) ? $bits[2] != 'false' : true;

				$this->loadModule($moduleName, $svnUrl, $devBuild);
			}
		}
	}

	/**
	 * Actually load the module!
	 *
	 * @param String $moduleName
	 * @param String $svnUrl
	 * @param boolean $devBuild
	 * 			Do we run a dev/build?
	 */
	protected function loadModule($moduleName, $svnUrl, $devBuild = true)
	{
		$git = strrpos($svnUrl, '.git') == (strlen($svnUrl) - 4);

		// check the module out if it doesn't exist
		if (!file_exists($moduleName)) {
			echo "Check out $moduleName from $svnUrl\n";
			// check whether it's git or svn
			if ($git) {
				echo `git clone $svnUrl $moduleName`;
			} else {
				echo `svn co $svnUrl $moduleName`;
			}

			// make sure to append it to the .gitignore file
			if (file_exists('.gitignore')) {
				$gitIgnore = file_get_contents('.gitignore');
				if (strpos($gitIgnore, $moduleName) === false) {
					`echo $moduleName >> .gitignore`;
				}
			}

		} else {
			echo "Updating $moduleName from $svnUrl\n";
			if ($git) {
				echo `cd $moduleName && git pull origin && cd ..`;
			} else {
				echo `svn up $moduleName`;
			}
		}

		if ($devBuild && file_exists('sapphire/cli-script.php')) {
			echo "Running dev/build\n";
			exec('php sapphire/cli-script.php dev/build', $output, $result);
		}
	}
}

?>
{'fraction_non_alphanumeric': 0.16943521594684385, 'fraction_numerical': 0.0027359781121751026, 'mean_word_length': 2.805204460966543, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 35, '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': '6510811', 'n_tokens_mistral': 2093, 'n_tokens_neox': 1792, 'n_words': 506}