ajwillia-ms pushed a commit to branch master.

http://git.enlightenment.org/website/www.git/commit/?id=60a6cb96c6f4c9cff84002a60b68f61a8b63a7e6

commit 60a6cb96c6f4c9cff84002a60b68f61a8b63a7e6
Author: Andy Williams <a...@andywilliams.me>
Date:   Wed Oct 25 13:14:15 2017 +0100

    Revert "Attempt upgrade to gitbacked plugin for ignorePath feature"
    
    This reverts commit b763c1067892dc83260b7431b1d5d198a347c9ea.
---
 .../lib/plugins/gitbacked/{README.md => README}    |  7 +--
 .../lib/plugins/gitbacked/action/editcommit.php    | 43 ++++---------
 public_html/lib/plugins/gitbacked/conf/default.php | 27 ++++++--
 .../lib/plugins/gitbacked/conf/metadata.php        |  3 +-
 .../lib/plugins/gitbacked/lang/en/settings.php     |  2 -
 public_html/lib/plugins/gitbacked/lib/Git.php      | 71 ++++++----------------
 public_html/lib/plugins/gitbacked/plugin.info.txt  |  6 +-
 7 files changed, 59 insertions(+), 100 deletions(-)

diff --git a/public_html/lib/plugins/gitbacked/README.md 
b/public_html/lib/plugins/gitbacked/README
similarity index 89%
rename from public_html/lib/plugins/gitbacked/README.md
rename to public_html/lib/plugins/gitbacked/README
index 9b1e9b2b..6ef56bbe 100644
--- a/public_html/lib/plugins/gitbacked/README.md
+++ b/public_html/lib/plugins/gitbacked/README
@@ -1,4 +1,4 @@
-# gitbacked Plugin for DokuWiki
+gitbacked Plugin for DokuWiki
 
 Store/Sync pages and media files in a git repository
 
@@ -6,14 +6,13 @@ All documentation for this plugin can be found at
 http://www.dokuwiki.org/plugin:gitbacked
 
 If you install this plugin manually, make sure it is installed in
-`lib/plugins/gitbacked/` - if the folder is called different it
+lib/plugins/gitbacked/ - if the folder is called different it
 will not work!
 
 Please refer to http://www.dokuwiki.org/plugins for additional info
 on how to install plugins in DokuWiki.
 
-## License
-
+----
 Copyright (C) Wolfgang Gassler <wolfg...@gassler.org>
 
 This program is free software; you can redistribute it and/or modify
diff --git a/public_html/lib/plugins/gitbacked/action/editcommit.php 
b/public_html/lib/plugins/gitbacked/action/editcommit.php
index 311c6ef9..a888e95e 100644
--- a/public_html/lib/plugins/gitbacked/action/editcommit.php
+++ b/public_html/lib/plugins/gitbacked/action/editcommit.php
@@ -24,7 +24,7 @@ class action_plugin_gitbacked_editcommit extends 
DokuWiki_Action_Plugin {
         io_mkdir_p($this->temp_dir);
     }
 
-    public function register(Doku_Event_Handler $controller) {
+    public function register(Doku_Event_Handler &$controller) {
 
         $controller->register_hook('IO_WIKIPAGE_WRITE', 'AFTER', $this, 
'handle_io_wikipage_write');
         $controller->register_hook('MEDIA_UPLOAD_FINISH', 'AFTER', $this, 
'handle_media_upload');
@@ -39,56 +39,35 @@ class action_plugin_gitbacked_editcommit extends 
DokuWiki_Action_Plugin {
         } else {
             $repoPath = DOKU_INC.$this->getConf('repoPath');
         }
-        //set the path to the git binary
-        $gitPath = trim($this->getConf('gitPath'));
-        if ($gitPath !== '') {
-            Git::set_bin($gitPath);
-        }
         //init the repo and create a new one if it is not present
         io_mkdir_p($repoPath);
         $repo = new GitRepo($repoPath, true, true);
         //set git working directory (by default DokuWiki's savedir)
         $repoWorkDir = DOKU_INC.$this->getConf('repoWorkDir');
-        Git::set_bin(Git::get_bin().' --work-tree 
'.escapeshellarg($repoWorkDir));
+        $repo->git_path .= ' --work-tree '.escapeshellarg($repoWorkDir);
 
         $params = str_replace(
             array('%mail%','%user%'),
             array($this->getAuthorMail(),$this->getAuthor()),
             $this->getConf('addParams'));
         if ($params) {
-            Git::set_bin(Git::get_bin().' '.$params);
+            $repo->git_path .= ' '.$params;
         }
         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) {
 
-               if (!$this->isIgnored($filePath)) {
-                       $repo = $this->initRepo();
+        $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 b01c3278..319a31e3 100644
--- a/public_html/lib/plugins/gitbacked/conf/default.php
+++ b/public_html/lib/plugins/gitbacked/conf/default.php
@@ -12,8 +12,27 @@ $conf['commitPageMsg']       = 'Wiki page %page% changed 
with summary [%summary%] by %
 $conf['commitPageMsgDel']      = 'Wiki page %page% deleted with reason 
[%summary%] by %user%';
 $conf['commitMediaMsg']        = 'Wiki media %media% uploaded by %user%';
 $conf['commitMediaMsgDel']     = 'Wiki media %media% deleted by %user%';
-$conf['repoPath'] = $GLOBALS['conf']['savedir'];
-$conf['repoWorkDir'] = $GLOBALS['conf']['savedir'];
-$conf['gitPath'] = '';
+$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
+ */
+$_git_auhor_name = 'www.enlightenment.org';
+$_git_auhor_mail = 'no-re...@enlightenment.org';
+
+if (isset($GLOBALS['USERINFO']['name'])) {
+  $_git_auhor_name = $GLOBALS['USERINFO']['name'];
+}
+
+if (isset($GLOBALS['USERINFO']['mail'])) {
+  $_git_auhor_mail = $GLOBALS['USERINFO']['mail'];
+}
+
+putenv("GIT_AUTHOR_NAME='$_git_auhor_name'");
+putenv("GIT_AUTHOR_EMAIL='$_git_auhor_mail'");
+
+/* plugin/gitbacked: Let access to ssh-agent */
+putenv("HOME=" . dirname($_SERVER['DOCUMENT_ROOT']));
+putenv("SSH_AUTH_SOCK=" . dirname($_SERVER['DOCUMENT_ROOT']) . "/.ssh/agent");
diff --git a/public_html/lib/plugins/gitbacked/conf/metadata.php 
b/public_html/lib/plugins/gitbacked/conf/metadata.php
index b71a89f1..d3bce744 100644
--- a/public_html/lib/plugins/gitbacked/conf/metadata.php
+++ b/public_html/lib/plugins/gitbacked/conf/metadata.php
@@ -14,6 +14,5 @@ $meta['commitMediaMsg'] = array('string');
 $meta['commitMediaMsgDel'] = array('string');
 $meta['repoPath'] = array('string');
 $meta['repoWorkDir'] = array('string');
-$meta['gitPath'] = 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 43089507..c5ff0080 100644
--- a/public_html/lib/plugins/gitbacked/lang/en/settings.php
+++ b/public_html/lib/plugins/gitbacked/lang/en/settings.php
@@ -15,6 +15,4 @@ $lang['commitMediaMsg']       = 'Commit message for media 
files (%user%,%media% are re
 $lang['commitMediaMsgDel']     = 'Commit message for deleted media files 
(%user%,%media% are replaced by the corresponding values)';
 $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['gitPath'] = 'Path to the git binary (if empty, the default 
"/usr/bin/git" will be used)';
 $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)';
diff --git a/public_html/lib/plugins/gitbacked/lib/Git.php 
b/public_html/lib/plugins/gitbacked/lib/Git.php
index be2f0b6b..6089d35e 100644
--- a/public_html/lib/plugins/gitbacked/lib/Git.php
+++ b/public_html/lib/plugins/gitbacked/lib/Git.php
@@ -48,7 +48,7 @@ class Git {
        public static function get_bin() {
                return self::$bin;
        }
-
+       
        /**
         * Sets up library for use in a default Windows environment
         */
@@ -82,21 +82,20 @@ class Git {
        public static function open($repo_path) {
                return new GitRepo($repo_path);
        }
-
+       
        /**
         * Clones a remote repo into a directory and then returns a GitRepo 
object
         * for the newly created local repo
-        *
+        * 
         * Accepts a creation path and a remote to clone from
-        *
+        * 
         * @access  public
         * @param   string  repository path
         * @param   string  remote source
-        * @param   string  reference path
         * @return  GitRepo
         **/
-       public static function &clone_remote($repo_path, $remote, $reference = 
null) {
-               return GitRepo::create_new($repo_path, $remote, true, 
$reference);
+       public static function &clone_remote($repo_path, $remote) {
+               return GitRepo::create_new($repo_path, $remote, true);
        }
 
        /**
@@ -138,23 +137,16 @@ class GitRepo {
         * @access  public
         * @param   string  repository path
         * @param   string  directory to source
-        * @param   string  reference path
         * @return  GitRepo
         */
-       public static function &create_new($repo_path, $source = null, 
$remote_source = false, $reference = null) {
+       public static function &create_new($repo_path, $source = null, 
$remote_source = false) {
                if (is_dir($repo_path) && file_exists($repo_path."/.git") && 
is_dir($repo_path."/.git")) {
                        throw new Exception('"'.$repo_path.'" is already a git 
repository');
                } else {
                        $repo = new self($repo_path, true, false);
                        if (is_string($source)) {
                                if ($remote_source) {
-                                       if (!is_dir($reference) || 
!is_dir($reference.'/.git')) {
-                                               throw new 
Exception('"'.$reference.'" is not a git repository. Cannot use as reference.');
-                                       } else if (strlen($reference)) {
-                                               $reference = 
realpath($reference);
-                                               $reference = "--reference 
$reference";
-                                       }
-                                       $repo->clone_remote($source, 
$reference);
+                                       $repo->clone_remote($source);
                                } else {
                                        $repo->clone_from($source);
                                }
@@ -238,16 +230,6 @@ class GitRepo {
        }
 
        /**
-        * Get the path to the git repo directory (eg. the ".git" directory)
-        * 
-        * @access public
-        * @return string
-        */
-       public function git_directory_path() {
-               return ($this->bare) ? $this->repo_path : 
$this->repo_path."/.git";
-       }
-
-       /**
         * Tests if git is installed
         *
         * @access  public
@@ -336,7 +318,7 @@ class GitRepo {
         * Runs a 'git status' call
         *
         * Accept a convert to HTML bool
-        *
+        * 
         * @access public
         * @param bool  return string with <br />
         * @return string
@@ -364,7 +346,7 @@ class GitRepo {
                }
                return $this->run("add $files -v");
        }
-
+       
        /**
         * Runs a `git rm` call
         *
@@ -390,12 +372,10 @@ class GitRepo {
         *
         * @access  public
         * @param   string  commit message
-        * @param   boolean  should all files be committed automatically (-a 
flag)
         * @return  string
         */
-       public function commit($message = "", $commit_all = true) {
-               $flags = $commit_all ? '-av' : '-v';
-               return $this->run("commit ".$flags." -m 
".escapeshellarg($message));
+       public function commit($message = "") {
+               return $this->run("commit -av -m ".escapeshellarg($message));
        }
 
        /**
@@ -434,11 +414,10 @@ class GitRepo {
         *
         * @access  public
         * @param   string  source url
-        * @param   string  reference path
         * @return  string
         */
-       public function clone_remote($source, $reference) {
-               return $this->run("clone $reference $source ".$this->repo_path);
+       public function clone_remote($source) {
+               return $this->run("clone $source ".$this->repo_path);
        }
 
        /**
@@ -590,7 +569,7 @@ class GitRepo {
                if ($message === null) {
                        $message = $tag;
                }
-               return $this->run("tag -a $tag -m " . escapeshellarg($message));
+               return $this->run("tag -a $tag -m $message");
        }
 
        /**
@@ -641,26 +620,12 @@ class GitRepo {
        }
 
        /**
-        * List log entries.
-        *
-        * @param strgin $format
-        * @return string
-        */
-       public function log($format = null) {
-               if ($format === null)
-                       return $this->run('log');
-               else
-                       return $this->run('log --pretty=format:"' . $format . 
'"');
-       }
-
-       /**
         * Sets the project description.
         *
         * @param string $new
         */
        public function set_description($new) {
-               $path = $this->git_directory_path();
-               file_put_contents($path."/description", $new);
+               file_put_contents($this->repo_path."/.git/description", $new);
        }
 
        /**
@@ -669,8 +634,7 @@ class GitRepo {
         * @return string
         */
        public function get_description() {
-               $path = $this->git_directory_path();
-               return file_get_contents($path."/description");
+               return file_get_contents($this->repo_path."/.git/description");
        }
 
        /**
@@ -686,3 +650,4 @@ class GitRepo {
 }
 
 /* End of file */
+
diff --git a/public_html/lib/plugins/gitbacked/plugin.info.txt 
b/public_html/lib/plugins/gitbacked/plugin.info.txt
index f3ac1ee0..15a80890 100644
--- a/public_html/lib/plugins/gitbacked/plugin.info.txt
+++ b/public_html/lib/plugins/gitbacked/plugin.info.txt
@@ -1,7 +1,7 @@
 base   gitbacked
-author Wolfgang Gassler (@woolfg), Carsten Teibes (@carstene1ns)
+author Wolfgang Gassler
 email  wolfg...@gassler.org
-date   2016-08-14
+date   2012-10-31
 name   gitbacked plugin
 desc   Pages and Media are stored in Git
-url    https://github.com/woolfg/dokuwiki-plugin-gitbacked
+url    https://github.com/woolfg/gitbacked

-- 


Reply via email to