<commit_before><?php
/**
 * Copyright 2017 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author   <NAME> <<EMAIL>>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL
 * @package  GitTools
 */

namespace Horde\GitTools\Action;

/**
 * Clone all repositories existing in specified organization.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2017 Horde LLC
 * @license   http://www.horde.org/licenses/lgpl LGPL
 * @package   GitTools
 */
class CloneRepositories extends Base
{
    const MODE = 0775;
    const HTTPS_GITURL = 'https://github.com';

    /**
     * Clones the specified package/repository.
     *
     * @param  string  $package  The repository name.
     * @param  boolean $app      If repository is an application, set to true.
     */
    public function run($package = '', $app = false)
    {
        // @todo validate the package name.
        //       validate the same type of checkout (dev/anon)?

        // Ensure the base directory exists.
        if (!file_exists($this->_params['git_base'])) {
            mkdir($this->_params['git_base'], self::MODE, true);
        }

        // Is this a developer checkout or anon?
        if (!empty($this->_user)) {
            // Do a developer checkout.
            // @todo
        } else {
            // Anon.
            $source = self::HTTPS_GITURL . '/' . $this->_params['org'] . '/' . $package . '.git';
            $target = $this->_params['git_base'] . '/' . ($app ? 'applications/' : '') . $package;
            passthru("git clone $source $target");
        }
    }
}<commit_msg>Support renaming repositories when linking.<commit_after><?php
/**
 * Copyright 2017 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file LICENSE for license information (LGPL). If you
 * did not receive this file, see http://www.horde.org/licenses/lgpl.
 *
 * @author   <NAME> <<EMAIL>>
 * @category Horde
 * @license  http://www.horde.org/licenses/lgpl LGPL
 * @package  GitTools
 */

namespace Horde\GitTools\Action;

/**
 * Clone all repositories existing in specified organization.
 *
 * @author    <NAME> <<EMAIL>>
 * @copyright 2017 Horde LLC
 * @license   http://www.horde.org/licenses/lgpl LGPL
 * @package   GitTools
 */
class CloneRepositories extends Base
{
    const MODE = 0775;
    const HTTPS_GITURL = 'https://github.com';

    /**
     * Clones the specified package/repository.
     *
     * @param  string  $package  The repository name.
     * @param  boolean $app      If repository is an application, set to true.
     */
    public function run($package = '', $app = false)
    {
        // @todo validate the package name.
        //       validate the same type of checkout (dev/anon)?

        // Ensure the base directory exists.
        if (!file_exists($this->_params['git_base'])) {
            mkdir($this->_params['git_base'], self::MODE, true);
        }

        // Check for any renaming
        if (!empty($this->_params['map'][$package])) {
            $package_webname = $this->_params['map'][$package];
        } else {
            $package_webname = $package;
        }

        // Is this a developer checkout or anon?
        if (!empty($this->_user)) {
            // Do a developer checkout.
            // @todo
        } else {
            // Anon.
            $source = self::HTTPS_GITURL . '/' . $this->_params['org'] . '/' . $package . '.git';
            $target = $this->_params['git_base'] . '/' . ($app ? 'applications/' : '') . $package_webname;
            passthru("git clone $source $target");
        }
    }
}
{'fraction_non_alphanumeric': 0.14853896103896103, 'fraction_numerical': 0.006493506493506494, 'mean_word_length': 2.19533275713051, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, 'https://': 2, 'lorem ipsum': 0, 'www.': 8, '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': '6063829', 'n_tokens_mistral': 1140, 'n_tokens_neox': 1094, 'n_words': 301}