Gitable/src/Ad5001/Gitable/Windows.php

144 lines
2.5 KiB
PHP
Raw Normal View History

2016-09-23 14:24:04 +00:00
<?php
namespace Ad5001\Gitable;
use pocketmine\Server;
use pocketmine\Player;
use Ad5001\Gitable\Main;
2016-09-23 16:30:14 +00:00
class Windows extends GitClient {
2016-09-23 18:52:41 +00:00
public function commit(string $message) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git commit -m \"$message\"", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function push(string $to = "github", string $from = "master") : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git push $to $from", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function checkout($branch = null) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch), 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function getBranch() : string {
$handle = popen('git branch', 'r');
$read = fread($handle, 2096);
return explode(" ", $read)[1];
}
public function branch($branch = '') : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git branch " . $branch, 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function start() : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git init", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function init() : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git init", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function getDir() {
return $this->dir;
}
public function cd($path) : string {
if(is_dir($path)) {
$dir = chdir($path);
$this->dir = getcwd();
return (string) $dir;
} else {
return "Directory $path not found !";
}
}
public function clone($from) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git clone $from", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function log() : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git log", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function remove($path) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git rm $path", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function move($path, $newpath) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git mv $path $newpath", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function add($path) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git add $path", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
2016-09-23 19:21:59 +00:00
public function diff() : string {
$handle = popen("git diff $path", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
2016-09-23 19:21:59 +00:00
public function status() : string {
$handle = popen("git status -s", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function remote($name, $url) : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git remote $name $url", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
public function pull($to = "github", $from = "master") : string {
2016-09-23 19:21:59 +00:00
$handle = popen("git pull $to $from", 'r');
return fread($handle, 2096);
2016-09-23 18:52:41 +00:00
}
}