projects
/
GITManagedWebpage.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fixed branch view with GLOBALS
[GITManagedWebpage.git]
/
GITManagedWebpage.class.php
diff --git
a/GITManagedWebpage.class.php
b/GITManagedWebpage.class.php
index 481bf143ecafcfea7fe91ae9ec2bc06cece07a0e..0522cc8ea39ac14b08691be4753000d503ef912a 100644
(file)
--- a/
GITManagedWebpage.class.php
+++ b/
GITManagedWebpage.class.php
@@
-90,7
+90,7
@@
class GITManagedWebpage {
} else
$argstr .= " ".escapeshellarg($arg);
}
} else
$argstr .= " ".escapeshellarg($arg);
}
- $gitcmd = 'git '.escapeshellarg('--git-dir='.$this->workdir.'repository/.git').' '.escapeshellarg('--work-tree='.$this->workdir.'repository
/.git
').$argstr;
+ $gitcmd = 'git '.escapeshellarg('--git-dir='.$this->workdir.'repository/.git').' '.escapeshellarg('--work-tree='.$this->workdir.'repository').$argstr;
$output = shell_exec($gitcmd);
return $output;
}
$output = shell_exec($gitcmd);
return $output;
}
@@
-103,6
+103,16
@@
class GITManagedWebpage {
$this->config_changed = true;
}
$this->config_changed = true;
}
+ private function checkConfigIntegrity() {
+ foreach($this->config as $key => $value) {
+ if(substr($key, 0, strlen('branch_')) == 'branch_') {
+ if(!file_exists($this->workdir.$key)) {
+ unset($this->config['key']);
+ }
+ }
+ }
+ }
+
/* private function getConfig($name)
* get an option from the configuration
*/
/* private function getConfig($name)
* get an option from the configuration
*/
@@
-113,6
+123,7
@@
class GITManagedWebpage {
if(file_exists($this->workdir."config.txt")) {
$config_txt = @file_get_contents($this->workdir."config.txt");
$this->config = unserialize($config_txt);
if(file_exists($this->workdir."config.txt")) {
$config_txt = @file_get_contents($this->workdir."config.txt");
$this->config = unserialize($config_txt);
+ $this->checkConfigIntegrity();
} else {
$this->config = array();
return null;
} else {
$this->config = array();
return null;
@@
-218,7
+229,7
@@
class GITManagedWebpage {
if($branch == $default_branch)
$dir = $this->localdir;
else
if($branch == $default_branch)
$dir = $this->localdir;
else
- $dir = $this->workdir.'branch_'.
$branch
.'/';
+ $dir = $this->workdir.'branch_'.
str_replace(array('/'), array('_'), $branch)
.'/';
if(file_exists($dir))
return $dir;
else if($create) {
if(file_exists($dir))
return $dir;
else if($create) {
@@
-228,7
+239,7
@@
class GITManagedWebpage {
return false;
}
return false;
}
- private function updateBranch($branch, $path) {
+ private function updateBranch($branch, $path
, $force = false
) {
if(substr($path, -1) != '/')
$path .= '/';
$current_branch = str_replace(array("\r", "\n"), array("", ""), $this->gitcmd("rev-parse", "--abbrev-ref", "HEAD"));
if(substr($path, -1) != '/')
$path .= '/';
$current_branch = str_replace(array("\r", "\n"), array("", ""), $this->gitcmd("rev-parse", "--abbrev-ref", "HEAD"));
@@
-241,7
+252,7
@@
class GITManagedWebpage {
$deleted_files = array();
if(($current_version = $this->getConfig('version_'.$branch))) {
$deleted_files = array();
if(($current_version = $this->getConfig('version_'.$branch))) {
- if($current_version == $newest_version)
+ if($current_version == $newest_version
&& !$force
)
return;
else {
$override_all = true;
return;
else {
$override_all = true;
@@
-290,17
+301,19
@@
class GITManagedWebpage {
if($this->loopedcall)
return;
if($this->loopedcall)
return;
- if(!$this->branchExists($branch))
- return false;
+ if(!$this->branchExists($branch)) {
+ if(!$this->branchExists('origin/'.$branch))
+ return false;
+ }
$this->setActiveBranch($branch, $remember);
if(!$this->localBranchPath($branch)) {
$dir = $this->localBranchPath($branch, true);
$this->setActiveBranch($branch, $remember);
if(!$this->localBranchPath($branch)) {
$dir = $this->localBranchPath($branch, true);
- $this->updateBranch($branch, $dir);
+ $this->updateBranch($branch, $dir
, true
);
}
}
}
}
- public function
execut
e($file = null) {
+ public function
getExecFil
e($file = null) {
if($this->loopedcall)
return;
define("GITMANAGED_EXECUTED", true);
if($this->loopedcall)
return;
define("GITMANAGED_EXECUTED", true);
@@
-315,10
+328,12
@@
class GITManagedWebpage {
if($active_branch != $default_branch) {
if(!($dir = $this->localBranchPath($branch))) {
$dir = $this->localBranchPath($active_branch, true);
if($active_branch != $default_branch) {
if(!($dir = $this->localBranchPath($branch))) {
$dir = $this->localBranchPath($active_branch, true);
- $this->updateBranch($active_branch, $dir);
+ $this->updateBranch($active_branch, $dir
, true
);
}
}
- include_once($dir.$file);
- die();
+ chdir($dir);
+ return $dir.$file;
+ } else {
+ return $file;
}
}
}
}