Almost finished windows....
This commit is contained in:
parent
298df3fca3
commit
0388b1afcd
2 changed files with 36 additions and 17 deletions
|
@ -39,15 +39,34 @@ class Main extends PluginBase implements Listener {
|
|||
|
||||
public function onEnable() {
|
||||
|
||||
@mkdir($this->getDataFolder());
|
||||
|
||||
@mkdir($this->getDataFolder() . "bin");
|
||||
|
||||
$this->getServer()->getPluginManager()->registerEvents($this, $this);
|
||||
$zip = new ZipArchive();
|
||||
|
||||
if(Utils::getOS() == "win") {
|
||||
if(!file_exists($this->getDataFolder() . "bin/git.exe") && $zip->open("../../resources/Windows.zip")) {
|
||||
$zip->extractTo($this->getDataFolder() . "bin");
|
||||
$zip->close();
|
||||
}
|
||||
$this->git = new Windows($this, $this->getDataFolder());
|
||||
} elseif(Utils::getOS() == "linux") {
|
||||
if(!file_exists($this->getDataFolder() . "bin/git.exe") && $zip->open("../../resources/Linux.zip")) {
|
||||
$zip->extractTo($this->getDataFolder() . "bin");
|
||||
$zip->close();
|
||||
}
|
||||
$this->git = new Linux($this, $this->getDataFolder());
|
||||
} elseif(Utils::getOS() == "mac") {
|
||||
if(!file_exists($this->getDataFolder() . "bin/git.exe") && $zip->open("../../resources/Mac.zip")) {
|
||||
$zip->extractTo($this->getDataFolder() . "bin");
|
||||
$zip->close();
|
||||
}
|
||||
$this->git = new Mac($this, $this->getDataFolder());
|
||||
} else {
|
||||
$this->getLogger()->critical("Unsuported device ! Please refer to the download page to see the list of available devices.");
|
||||
$this->setEnable(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,44 +27,44 @@ class Windows extends GitClient {
|
|||
|
||||
|
||||
public function commit(string $message) : string {
|
||||
$handle = popen("git commit -m \"$message\"", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe commit -m \"$message\"", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function push(string $to ="github", string $from = "master") : string {
|
||||
$handle = popen("git push $to $from", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe push $to $from", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function checkout($branch = null) : string {
|
||||
$handle = popen("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch), 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe checkout " . (!is_null($branch) ? $this->getBranch() : $branch), 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function getBranch() : string {
|
||||
$handle = popen('git branch', 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe branch", 'r');
|
||||
$read = fread($handle, 2096);
|
||||
return explode(" ", $read)[1];
|
||||
}
|
||||
|
||||
|
||||
public function branch($branch = '') : string {
|
||||
$handle = popen("git branch " . $branch, 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe branch " . $branch, 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function start() : string {
|
||||
$handle = popen("git init", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe init", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function init() : string {
|
||||
$handle = popen("git init", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe init", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
@ -85,55 +85,55 @@ class Windows extends GitClient {
|
|||
|
||||
|
||||
public function clone($from) : string {
|
||||
$handle = popen("git clone $from", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe clone $from", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function log() : string {
|
||||
$handle = popen("git log", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe log", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function remove($path) : string {
|
||||
$handle = popen("git rm $path", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe rm $path", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function move($path, $newpath) : string {
|
||||
$handle = popen("git mv $path $newpath", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe mv $path $newpath", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function add($path) : string {
|
||||
$handle = popen("git add $path", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe add $path", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function diff() : string {
|
||||
$handle = popen("git diff $path", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe diff $path", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function status() : string {
|
||||
$handle = popen("git status -s", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe status -s", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function remote($name, $url) : string {
|
||||
$handle = popen("git remote $name $url", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe remote $name $url", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
||||
public function pull($to = "github", $from = "master") : string {
|
||||
$handle = popen("git pull $to $from", 'r');
|
||||
$handle = popen($this->getDataFolder() . "bin/git.exe pull $to $from", 'r');
|
||||
return fread($handle, 2096);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue