예제 #1
0
 /**
  * Returns the path to the top-level Git directory.
  * @access public
  * @return string The path to the top-level Git directory.
  */
 public function get_git_dir()
 {
     if (defined('REVISR_GIT_DIR') && is_dir(REVISR_GIT_DIR)) {
         // Force removal of trailing slash upfront.
         $git_dir = rtrim(REVISR_GIT_DIR, DIRECTORY_SEPARATOR);
         if (is_dir(REVISR_GIT_DIR . DIRECTORY_SEPARATOR . '.git')) {
             // Workaround for backwards compatibility.
             if (!defined('REVISR_WORK_TREE')) {
                 // Define the REVISR_WORK_TREE constant to match the old REVISR_GIT_DIR constant.
                 define('REVISR_WORK_TREE', REVISR_GIT_DIR);
                 $line = "define('REVISR_WORK_TREE', '" . REVISR_GIT_DIR . "');";
                 Revisr_Admin::replace_config_line('define *\\( *\'REVISR_WORK_TREE\'', $line);
                 // Update the old REVISR_GIT_DIR constant.
                 $git_dir = REVISR_GIT_DIR . DIRECTORY_SEPARATOR . '.git';
                 $line = "define('REVISR_GIT_DIR', '" . REVISR_GIT_DIR . DIRECTORY_SEPARATOR . ".git');";
                 Revisr_Admin::replace_config_line('define *\\( *\'REVISR_GIT_DIR\'', $line);
             }
         } else {
             $git_dir = REVISR_GIT_DIR;
         }
     } else {
         // Best guess.
         $git_dir = $this->get_work_tree() . DIRECTORY_SEPARATOR . '.git';
     }
     return $git_dir;
 }
예제 #2
0
    /**
     * Displays/updates the "Git Path" settings field.
     * @access public
     */
    public function git_path_callback()
    {
        $git_path = defined('REVISR_GIT_PATH') ? REVISR_GIT_PATH : '';
        if (isset($_GET['settings-updated'])) {
            $dir = revisr()->options['git_path'];
            $line = "define('REVISR_GIT_PATH', '{$dir}');";
            Revisr_Admin::replace_config_line('define *\\( *\'REVISR_GIT_PATH\'', $line);
            $git_path = revisr()->options['git_path'];
        }
        printf('<input type="text" id="git_path" name="revisr_general_settings[git_path]" class="regular-text revisr-text" value="%s" />
			<p class="description revisr-description">%s</p>', esc_attr($git_path), __('If necessary, you can define the installation path to Git here.', 'revisr'));
    }
예제 #3
0
파일: setup.php 프로젝트: acchs/test
    $gitignore = array();
    $dir = $tracking;
    // Customize .gitignore & git dir as necessary.
    switch ($tracking) {
        case ABSPATH:
            $gitignore = array('.htaccess', 'wp-config.php');
            break;
        case WP_CONTENT_DIR:
            break;
        case 'single':
            $dir = $plugin_or_theme;
            break;
    }
    // Write it to the wp-config file if necessary.
    $line = "define('REVISR_WORK_TREE', '{$dir}');";
    Revisr_Admin::replace_config_line('define *\\( *\'REVISR_WORK_TREE\'', $line);
    // Refresh the 'Revisr_Git' instance.
    revisr()->git = new Revisr_Git();
    // Create the .gitignore file BEFORE repo creation.
    $gitignore_file = revisr()->git->get_work_tree() . DIRECTORY_SEPARATOR . '.gitignore';
    if (!file_exists($gitignore_file) && !empty($gitignore)) {
        file_put_contents($gitignore_file, implode(PHP_EOL, $gitignore));
    }
    ?>

				<p><?php 
    _e('Attempting to create repository...', 'revisr');
    ?>
</p>

				<?php