当前位置: 首页>>代码示例>>PHP>>正文


PHP Git::create方法代码示例

本文整理汇总了PHP中Git::create方法的典型用法代码示例。如果您正苦于以下问题:PHP Git::create方法的具体用法?PHP Git::create怎么用?PHP Git::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Git的用法示例。


在下文中一共展示了Git::create方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeSave

 function beforeSave()
 {
     if (!$this['type']) {
         throw $this->exception('Please specify type', 'ValidityCheck')->setField('type');
     }
     $existing_check = $this->add('Model_MarketPlace');
     $existing_check->addCondition('id', '<>', $this->id);
     $existing_check->addCondition('namespace', $this['namespace']);
     $existing_check->tryLoadAny();
     if ($existing_check->loaded()) {
         throw $this->exception('Name Space Already Used', 'ValidityCheck')->setField('namespace');
     }
     // TODO :: check namespace on server as well...
     if (file_exists(getcwd() . DS . 'epan-components' . DS . $this['namespace']) and !$this->isInstalling) {
         throw $this->exception('namespace folder is already created', 'ValidityCheck')->setField('namespace');
     }
     if (!$this->isInstalling) {
         //Added in AddComponentTorepository View
         $create_component_folder = true;
         if ($this['initialize_and_clone_from_git'] and $this['git_path']) {
             $repo = Git::create($dest = getcwd() . DS . 'epan-components' . DS . $this['namespace'], $this['git_path']);
             $create_component_folder = false;
         }
         $this->createNewFiles($create_component_folder);
     }
 }
开发者ID:xepan,项目名称:xepan,代码行数:26,代码来源:MarketPlace.php

示例2: update

 function update($dynamic_model_update = true)
 {
     if ($this->git_path == null) {
         throw $this->exception('public variable git_path must be defined in page class');
     }
     $class = get_class($this);
     preg_match('/page_(.*)_page_(.*)/', $class, $match);
     $this->component_namespace = $match[1];
     $mp = $this->add('Model_MarketPlace')->loadBy('namespace', $this->component_namespace);
     $this->component_name = $mp['name'];
     $component_path = getcwd() . DS . 'epan-components' . DS . $this->component_namespace;
     if ($_GET['git_exec_path']) {
         Git::set_bin($_GET['git_exec_path']);
     }
     try {
         if (file_exists($component_path . DS . '.git')) {
             $repo = Git::open($component_path);
         } else {
             $repo = Git::create($component_path);
         }
     } catch (Exception $e) {
         // No Git Found ... So just return
         return;
     }
     $remote_branches = $repo->list_remote_branches();
     if (count($remote_branches) == 0) {
         $repo->add_remote_address($this->git_path);
     }
     $branch = 'master';
     if ($_GET['git_branch']) {
         $branch = $_GET['git_branch'];
     }
     $repo->run('fetch --all');
     $repo->run('reset --hard origin/' . $branch);
     if ($dynamic_model_update) {
         $dir = $component_path . DS . 'lib' . DS . 'Model';
         if (file_exists($dir)) {
             $lst = scandir($dir);
             array_shift($lst);
             array_shift($lst);
             foreach ($lst as $item) {
                 $model = $this->add($this->component_namespace . '/Model_' . str_replace(".php", '', $item));
                 $model->add('dynamic_model/Controller_AutoCreator');
                 $model->tryLoadAny();
             }
         }
     }
     // Re process Config file
     $this->add('Model_MarketPlace')->loadBy('namespace', $this->component_namespace)->reProcessConfig();
     // Get new code from git
     // Get all models in lib/Model
     // add dynamic line on object
     // tryLoanAny
 }
开发者ID:xepan,项目名称:xepan,代码行数:54,代码来源:update.php

示例3: create_note

 function create_note($author_id, $author_pseudo, $author_email, $path, $note_name, $file_name, $cat_id)
 {
     $git_repo = Git::create($path);
     $git_repo->run("config user.name \"{$author_pseudo}\"");
     $git_repo->run("config user.email \"{$author_email}\"");
     $git_repo->add();
     $git_repo->commit('Première version');
     //insert data on database
     $note_array = array('path' => $path, 'file_name' => $file_name, 'name' => $note_name, 'visible' => 1, 'category' => $cat_id, 'author_id' => $author_id, 'creation_date' => date("Y-m-d H:i:s"), 'modification_date' => date("Y-m-d H:i:s"));
     $this->db->insert('note', $note_array);
     $note_id = $this->db->insert_id();
     return $note_id;
 }
开发者ID:Natsuke,项目名称:Projet-integration-Open-Note,代码行数:13,代码来源:notes_model.php

示例4: setupDevRepos

 /**
  * Setup GIT Repos from Stash
  *
  * Lists all repos from remote project and downloaded them, skipping devtools
  *
  * @param   string $directory Directory to work with
  * @param   bool $force True or False on whether to rm -Rf and then recreate the repo
  * @return  array
  */
 function setupDevRepos($directory, $force = false, $mode = 'ssh', $branch = 'master', $project_key = 'freepbx')
 {
     $skipr = array('devtools', 'moh_sounds', 'versionupgrade', 'fw_langpacks', 'custom-freepbx-modules', 'sipstation_module');
     $o = $this->stash->getAllRepos($project_key);
     if ($mode == 'http' && version_compare(Git::version(), '1.7.9', '<')) {
         freepbx::out("HTTP Mode is only supported with GIT 1.7.9 or Higher");
         die;
     } elseif ($mode == 'http') {
         Git::enable_credential_cache();
     }
     foreach ($o['values'] as $repos) {
         $dir = $directory . '/' . $repos['name'];
         if (in_array($repos['name'], $skipr)) {
             continue;
         }
         freepbx::outn("Cloning " . $repos['name'] . " into " . $dir . "...");
         if (file_exists($dir) && $force) {
             freepbx::out($dir . " Already Exists but force is enabled so deleting and restoring");
             exec('rm -Rf ' . $dir);
         } elseif (file_exists($dir)) {
             freepbx::out($dir . " Already Exists, Skipping (use --force to force)");
             continue;
         }
         $uri = $mode == 'http' ? $repos['cloneUrl'] : $repos['cloneSSH'];
         $repo = Git::create($dir, $uri);
         $repo->add_merge_driver();
         freepbx::out("Done");
         $obranch = $branch;
         while ($branch) {
             try {
                 freepbx::outn("\tChecking you out into the " . $branch . " branch...");
                 $repo->checkout($branch);
                 freepbx::out("Done");
                 break;
             } catch (Exception $e) {
                 freepbx::out("Doesnt Exist!");
                 $branch = $this->getLowerBranch($branch);
                 if ($branch === false) {
                     try {
                         freepbx::outn("\tChecking you out into the master branch...");
                         $repo->checkout('master');
                         freepbx::out("Done");
                     } catch (Exception $e) {
                         //TODO: error?
                     }
                 }
             }
         }
         $branch = $obranch;
         freepbx::out(" ");
     }
 }
开发者ID:FreePBX,项目名称:devtools,代码行数:61,代码来源:freepbx.php

示例5: foreach

         foreach ($projects as $project => $description) {
             $repo = $stash->getRepo($options['m'], $project);
             if ($repo === false) {
                 freepbx::out("[WARN] " . $options['m'] . " is NOT in the " . $description);
             } else {
                 break;
             }
         }
         if ($repo === false) {
             freepbx::out("[ERROR] Unable to find " . $options['m']);
             exit(0);
         }
         $uri = $mode == 'http' ? $repo['cloneUrl'] : $repo['cloneSSH'];
         $dir = $directory . '/' . $options['m'];
         freepbx::out("Cloning " . $repo['name'] . " into " . $dir);
         $repo = Git::create($dir, $uri);
         $repo->add_merge_driver();
         freepbx::out("Done");
         $freepbx = new freepbx($username, $password);
         $freepbx->setupSymLinks($directory);
     }
 } else {
     freepbx::out("Module Already Exists");
     if (!file_exists($directory . '/framework/amp_conf/htdocs/admin/modules/' . $options['m'])) {
         $username = freepbx::getInput("FreePBX Username");
         $password = freepbx::getPassword("FreePBX Password", true);
         $freepbx = new freepbx($username, $password);
         $freepbx->setupSymLinks($directory);
     }
 }
 if (empty($vars['dev_symlinks'])) {
开发者ID:FreePBX,项目名称:devtools,代码行数:31,代码来源:freepbx_git.php

示例6: testDelete

 function testDelete()
 {
     $Git->logReponse = true;
     $Git = new Git($this->__repos[1]);
     $this->assertTrue($Git->create());
     $this->assertTrue(file_exists(TMP . 'tests/git/repo/test.git'));
     $this->assertTrue(file_exists(TMP . 'tests/git/working/test/master/.git'));
     $Git->run('branch new');
     $Git->update();
     $Git->branch('new', true);
     $this->assertTrue($Git->delete());
     $Git->branch('master', true);
     $results = $Git->find('branches');
     $this->assertEqual($results, array('master'));
     //pr($Git->debug);
     //pr($Git->response);
     //die();
 }
开发者ID:Theaxiom,项目名称:chaw-source,代码行数:18,代码来源:git.test.php

示例7: array

    } else {
        $return = array(1, "Git could not be found at the default location");
    }
    return $return;
}, 'Git::create()' => function () {
    $return = null;
    $repo = Git::create(DIR . "/create");
    if (!Git::is_repo($repo)) {
        $return = array(2, "Git::create() failed to produce expected output.");
    } else {
        $return = array(0, "Git::create() executed successfully");
    }
    return $return;
}, 'Git::create([ $source ])' => function () {
    $return = null;
    $repo = Git::create(DIR . "/createfrom", DIR . "/test.git");
    if (!Git::is_repo($repo)) {
        $return = array(2, "Git::create([ \$source ]) failed to produce expected output.");
    } else {
        $return = array(0, "Git::create([ \$source ]) executed successfully");
    }
    return $return;
}, 'Git::open()' => function () {
    $return = null;
    $repo = Git::open(DIR . "/test.git");
    if (!Git::is_repo($repo)) {
        $return = array(2, "Git::open() failed to produce expected output.");
    } else {
        $return = array(0, "Git::open() executed successfully");
    }
    return $return;
开发者ID:Llewellynvdm,项目名称:Git.php,代码行数:31,代码来源:test-suite.php

示例8: get_update

function get_update($sname, $file_lock, $base_url, $path, $mail_lock, $remote_git = '', $remote_branch = '')
{
    session_name($sname);
    session_start();
    set_time_limit(300);
    ignore_user_abort(true);
    $stime = time();
    $work = false;
    //检测、设置工作标志,存在session里(同一个session_name在一个页面未结束前会保持读写锁状态)
    if (empty($_SESSION['working'])) {
        $work = true;
    }
    if (file_exists($file_lock)) {
        $last_work_time = filemtime($file_lock);
        if ($last_work_time > 0 && time() - $last_work_time < 120) {
            //上次更新至今有120秒
            echo "检测到正在进行工作中,本页面停止载入,请稍后再次访问。";
            return false;
            //exit;
        }
        $work = true;
        unlink($file_lock);
    } elseif (empty($_SESSION['work_time']) || $stime - $_SESSION['work_time'] > LOCK_TIME) {
        //保证 LOCK_TIME 秒内只访问一次
        $work = true;
    }
    if ($work && !file_exists($file_lock)) {
        $_SESSION['working'] = true;
        $_SESSION['work_time'] = $stime;
        file_put_contents($file_lock, $stime);
    } else {
        echo "距离上次获取请求时间间隔多短,请稍后再次访问。";
        return false;
        //exit;
    }
    echo date("Y-m-d H:i:s") . " 读取列表中...<br>";
    $list = get_list($base_url);
    //获取列表
    if (count($list) < 2) {
        echo "读取Wiki列表失败,等待下次检测。<br>";
        $_SESSION['work_time'] = $stime - LOCK_TIME;
        //取消检查时间,让检测可在稍后再次发起
        unlink($file_lock);
        return false;
    }
    session_write_close();
    //解除session,防止使其他访问页面一直等待session
    mk_dir($path);
    if (IS_WIN) {
        Git::windows_mode();
    }
    if (!file_exists($path . '.git')) {
        echo date("Y-m-d H:i:s") . " 没有git库,尝试创建...<br>";
        if ($remote_git) {
            //是否设置了远程仓库
            echo "尝试从远程仓库克隆数据...<br>";
            $ret = Git::clone_remote($path, $remote_git, $remote_branch);
            //从远程仓库clone(可指定分支)
            if (!Git::is_repo($ret) || !file_exists($path . '.git') || !$ret) {
                echo "从远程仓库克隆失败,本地创建...<br>";
                $ret = Git::create($path);
                //如果clone失败,则本地创建
            }
        } else {
            $ret = Git::create($path);
        }
        //直接本地创建
        echo date("Y-m-d H:i:s") . " 创建结果:" . (Git::is_repo($ret) ? '成功' : '失败') . "<br>";
    }
    $files = ls_file($path);
    foreach ($files as $file) {
        if (!is_dir($path . $file)) {
            unlink($path . $file);
        }
    }
    $tmp_arr = parse_url($base_url);
    $url_base = $tmp_arr['scheme'] . '://' . $tmp_arr['host'];
    write($path . 'list.txt', json($list));
    //写出列表
    echo date("Y-m-d H:i:s") . " 读取wiki列表完毕,开始读取内容页...<br>";
    $count = 0;
    $content = get_content($base_url);
    write($path . 'index.html', $content);
    $count++;
    foreach ($list as $arr) {
        if (isset($arr['ul'])) {
            foreach ($arr['ul'] as $a) {
                if (substr($a['url'], 0, 1) == '.' || substr($a['url'], 0, 1) == '/') {
                    //地址以.或/开头,则为wiki文档
                    $content = get_content((substr($a['url'], 0, 1) == '/' ? $url_base : (substr($a['url'], 0, 1) == '.' ? $url_base . $tmp_arr['path'] : '')) . $a['url']);
                    if ($content) {
                        write($path . $a['title'] . '.html', $content);
                        $count++;
                    }
                }
            }
        }
    }
    echo date("Y-m-d H:i:s") . " 获取操作完成,读取页面数量:" . $count . "<br>";
    $repo = Git::open($path);
//.........这里部分代码省略.........
开发者ID:l1291434519,项目名称:MpWiki_check,代码行数:101,代码来源:Base.php

示例9: update

 function update($dynamic_model_update = true, $git_exec_path = null, $git_branch = 'master')
 {
     if ($this->git_path == null) {
         throw $this->exception('public variable git_path must be defined in page class');
     }
     $installation_path = getcwd();
     if ($git_exec_path) {
         Git::set_bin($git_exec_path);
     }
     if (file_exists($installation_path . DS . '.git')) {
         $repo = Git::open($installation_path);
     } else {
         $repo = Git::create($installation_path);
     }
     $remote_branches = $repo->list_remote_branches();
     if (count($remote_branches) == 0) {
         $repo->add_remote_address($this->git_path);
     }
     $repo->run('fetch --all');
     $repo->run('reset --hard origin/' . $git_branch);
     if ($dynamic_model_update) {
         $model = $this->add('Model_Branch');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Staff');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanCategory');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Epan');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanTemplates');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanPage');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_EpanPageSnapshots');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_MarketPlace');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_InstalledComponents');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Tools');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Plugins');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Alerts');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Aliases');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Messages');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
         $model = $this->add('Model_Users');
         $model->add('dynamic_model/Controller_AutoCreator');
         $model->tryLoadAny();
     }
     // fire queries to convert superuser to 100 etc
     $this->query('UPDATE users SET type=IF(type="SuperUser",100,IF(type="BackEndUser",80,IF(type=100,100,50)))');
     // change users type to int
     $this->query('ALTER TABLE `users` CHANGE `type` `type` INT NULL DEFAULT NULL');
     // re Process base Element Config
     $base_element_market_place = $this->add('Model_MarketPlace')->loadBy('namespace', 'baseElements');
     $base_element_market_place->reProcessConfig();
 }
开发者ID:xepan,项目名称:xepan,代码行数:75,代码来源:updater.php


注:本文中的Git::create方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。