Working on it.

This commit is contained in:
Ad5001 2016-09-23 19:30:14 +03:00
parent 996d1791e6
commit 76d4e60d53
3 changed files with 82 additions and 24 deletions

View file

@ -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;
}

View file

@ -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());
}
}

View file

@ -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 {}
}