diff --git a/src/Ad5001/Gitable/GitClient.php b/src/Ad5001/Gitable/GitClient.php index 1cebb54..8daf5d0 100644 --- a/src/Ad5001/Gitable/GitClient.php +++ b/src/Ad5001/Gitable/GitClient.php @@ -33,6 +33,8 @@ abstract class GitClient { $this->dir = $dir; + $this->cd($dir); + } @@ -43,13 +45,13 @@ abstract class GitClient { public abstract function push(string $to = "github", string $from = "master") : string; - public abstract function undoCommit() : string; + public abstract function checkout($branch = null) : string; - public abstract function checkout($message) : string; + public abstract function getBranch() : string; - public abstract function branch($message) : string; + public abstract function branch($branch = '') : string; public abstract function start() : string; @@ -68,16 +70,13 @@ abstract class GitClient { public abstract function clone($from) : string; - public abstract function logs() : string; + public abstract function log() : string; public abstract function remove($path) : string; - public abstract function move($path) : string; - - - public abstract function headreset() : string; + public abstract function move($path, $newpath) : string; public abstract function add($path) : string; @@ -95,7 +94,4 @@ abstract class GitClient { public abstract function pull($to = "github", $from = "master") : string; - public abstract function status($path) : string; - - } \ No newline at end of file diff --git a/src/Ad5001/Gitable/Main.php b/src/Ad5001/Gitable/Main.php index 041d950..794b119 100644 --- a/src/Ad5001/Gitable/Main.php +++ b/src/Ad5001/Gitable/Main.php @@ -38,11 +38,11 @@ class Main extends PluginBase implements Listener { $this->getServer()->getPluginManager()->registerEvents($this, $this); if(Utils::getOS() == "win") { - $this->git = new Windows($this); + $this->git = new Windows($this, $this->getDataFolder()); } elseif(Utils::getOS() == "linux") { - $this->git = new Linux($this); + $this->git = new Linux($this, $this->getDataFolder()); } elseif(Utils::getOS() == "mac") { - $this->git = new Mac($this); + $this->git = new Mac($this, $this->getDataFolder()); } } diff --git a/src/Ad5001/Gitable/Windows.php b/src/Ad5001/Gitable/Windows.php index 26f7856..223e299 100644 --- a/src/Ad5001/Gitable/Windows.php +++ b/src/Ad5001/Gitable/Windows.php @@ -20,23 +20,85 @@ use Ad5001\Gitable\Main; -class Windows { +class Windows extends GitClient { - public function __construct(Main $main) { - - - $this->main = $main; - - - $this->server = $main->getServer(); - - + + public function commit(string $message) : string { + return shell_exec("git commit -m \"$message\""); } + public function push(string $to = "github", string $from = "master") : string { + return shell_exec("git push $to $from"); + } + + + public function checkout($branch = null) : string { + return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch)); + } + + + public function getBranch() : string { + $handle = popen('git branch', 'r'); + $read = fread($handle, 2096); + return explode(" ", $read)[1]; + } + + + public function branch($branch = '') : string { + return shell_exec("git branch " . $branch); + } + + + public function start() : string { + return shell_exec("git init"); + } + + + public function init() : string { + return shell_exec("git init"); + } + + public function getDir() { + return $this->dir; + } + + + public function cd($path) : string { + return shell_exec("cd " . $path); + } + + + public function clone($from) : string {} + + + public function log() : string {} + + + public function remove($path) : string {} + + + public function move($path, $newpath) : string {} + + + public function add($path) : string {} + + + public function diff($path) : string {} + + + public function status($path) : string {} + + + public function remote($name, $url) : string {} + + + public function pull($to = "github", $from = "master") : string {} + + } \ No newline at end of file