1<?php 2/** 3 * @license GPL 2 (http://www.gnu.org/licenses/gpl.html) 4 * @author Stephan Dekker <Stephan@SparklingSoftware.com.au> 5 */ 6 7if(!defined('DOKU_PLUGIN')) define('DOKU_PLUGIN',DOKU_INC.'lib/plugins/'); 8require_once DOKU_PLUGIN.'action.php'; 9require_once(DOKU_PLUGIN.'git/lib/Git.php'); 10 11 12class action_plugin_git_merge extends DokuWiki_Action_Plugin { 13 14 var $helper = null; 15 16 function action_plugin_git_merge (){ 17 $this->helper =& plugin_load('helper', 'git'); 18 if(!$this->helper) msg('Loading the git helper failed.',-1); 19 } 20 21 function register(&$controller) { 22 $controller->register_hook('TPL_METAHEADER_OUTPUT', 'BEFORE', $this, '_handle'); 23 } 24 25 function _handle(&$event, $param) { 26 27 if ($_REQUEST['cmd'] === null) return; 28 29 // verify valid values 30 switch (key($_REQUEST['cmd'])) { 31 case 'merge' : $this->pull(); break; 32 case 'ignore' : $this->ignore(); break; 33 } 34 } 35 36 function pull() 37 { 38 try { 39 global $conf; 40 $this->getConf(''); 41 42 $git_exe_path = $conf['plugin']['git']['git_exe_path']; 43 $datapath = $conf['savedir']; 44 45 $repo = new GitRepo($datapath); 46 $repo->git_path = $git_exe_path; 47 $repo->pull('origin', 'master'); 48 49 if(!$this->helper) { 50 msg('GIT helper is null in the merge.php file'); 51 return; 52 } 53 $this->helper->resetGitStatusCache('upstream'); 54 $this->helper->rebuild_data_plugin_data(); 55 } 56 catch(Exception $e) 57 { 58 msg($e->getMessage()); 59 return false; 60 } 61 } 62 63 function ignore() 64 { 65 $hash = $_REQUEST['hash']; 66 //$this->output('Ignoring: '.$hash); 67 } 68}