ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/website/www.git/commit/?id=459fdf601a363c102e3e63d3e38ebbf84b5a7d0d

commit 459fdf601a363c102e3e63d3e38ebbf84b5a7d0d
Author: Andy Williams <a...@andywilliams.me>
Date:   Wed Oct 25 13:19:19 2017 +0100

    Add ignorePaths feature to gitbacked via patch until we can get upgrade 
working
---
 .../lib/plugins/gitbacked/action/editcommit.php    | 32 ++++++++++++++++------
 public_html/lib/plugins/gitbacked/conf/default.php |  1 +
 .../lib/plugins/gitbacked/conf/metadata.php        |  1 +
 .../lib/plugins/gitbacked/lang/en/settings.php     |  1 +
 4 files changed, 27 insertions(+), 8 deletions(-)

diff --git a/public_html/lib/plugins/gitbacked/action/editcommit.php 
b/public_html/lib/plugins/gitbacked/action/editcommit.php
index a888e95e..0094bf4e 100644
--- a/public_html/lib/plugins/gitbacked/action/editcommit.php
+++ b/public_html/lib/plugins/gitbacked/action/editcommit.php
@@ -56,18 +56,34 @@ class action_plugin_gitbacked_editcommit extends 
DokuWiki_Action_Plugin {
         return $repo;
     }
 
+       private function isIgnored($filePath) {
+               $ignore = false;
+               $ignorePaths = trim($this->getConf('ignorePaths'));
+               if ($ignorePaths !== '') {
+                       $paths = explode(',',$ignorePaths);
+                       foreach($paths as $path) {
+                               if (strstr($filePath,$path)) {
+                                       $ignore = true;
+                               }
+                       }
+               }
+               return $ignore;
+       }
+
     private function commitFile($filePath,$message) {
 
-        $repo = $this->initRepo();
+               if (!$this->isIgnored($filePath)) {
+                       $repo = $this->initRepo();
 
-        //add the changed file and set the commit message
-        $repo->add($filePath);
-        $repo->commit($message);
+                       //add the changed file and set the commit message
+                       $repo->add($filePath);
+                       $repo->commit($message);
 
-        //if the push after Commit option is set we push the active branch to 
origin
-        if ($this->getConf('pushAfterCommit')) {
-            $repo->push('origin',$repo->active_branch());
-        }
+                       //if the push after Commit option is set we push the 
active branch to origin
+                       if ($this->getConf('pushAfterCommit')) {
+                               $repo->push('origin',$repo->active_branch());
+                       }
+               }
 
     }
 
diff --git a/public_html/lib/plugins/gitbacked/conf/default.php 
b/public_html/lib/plugins/gitbacked/conf/default.php
index 319a31e3..b40bc6c8 100644
--- a/public_html/lib/plugins/gitbacked/conf/default.php
+++ b/public_html/lib/plugins/gitbacked/conf/default.php
@@ -15,6 +15,7 @@ $conf['commitMediaMsgDel']    = 'Wiki media %media% deleted 
by %user%';
 $conf['repoPath']      = $GLOBALS['conf']['savedir'];
 $conf['repoWorkDir']   = $GLOBALS['conf']['savedir'];
 $conf['addParams'] = '';
+$conf['ignorePaths'] = '';
 
 /* plugin/gitbacked: Define a nice author (until addParams is fixed)
  * MUST NOT be defined in conf/local.php as $GLOBALS['USERINFO'] does not yet 
exist there
diff --git a/public_html/lib/plugins/gitbacked/conf/metadata.php 
b/public_html/lib/plugins/gitbacked/conf/metadata.php
index d3bce744..05f53bf3 100644
--- a/public_html/lib/plugins/gitbacked/conf/metadata.php
+++ b/public_html/lib/plugins/gitbacked/conf/metadata.php
@@ -15,4 +15,5 @@ $meta['commitMediaMsgDel'] = array('string');
 $meta['repoPath'] = array('string');
 $meta['repoWorkDir'] = array('string');
 $meta['addParams'] = array('string');
+$meta['ignorePaths'] = array('string');
 
diff --git a/public_html/lib/plugins/gitbacked/lang/en/settings.php 
b/public_html/lib/plugins/gitbacked/lang/en/settings.php
index c5ff0080..b5b7ce00 100644
--- a/public_html/lib/plugins/gitbacked/lang/en/settings.php
+++ b/public_html/lib/plugins/gitbacked/lang/en/settings.php
@@ -16,3 +16,4 @@ $lang['commitMediaMsgDel']    = 'Commit message for deleted 
media files (%user%,%me
 $lang['repoPath']      = 'Path of the git repo (e.g. the savedir 
'.$GLOBALS['conf']['savedir'].')';
 $lang['repoWorkDir']   = 'Path of the git working tree, must contain "pages" 
and "media" directories (e.g. the savedir '.$GLOBALS['conf']['savedir'].')';
 $lang['addParams'] = 'Additional git parameters (added to the git execution 
command) (%user% and %mail% are replaced by the corresponding values)';
+$lang['ignorePaths'] = 'Paths/files which are ignored and not added to git 
(comma-separated)';
\ No newline at end of file

-- 


Reply via email to