Browse Source

Making some changes ...

tags/v1.0
Ad5001 3 years ago
parent
commit
298df3fca3
3 changed files with 53 additions and 11 deletions
  1. 1
    1
      src/Ad5001/Gitable/GitClient.php
  2. 20
    2
      src/Ad5001/Gitable/Main.php
  3. 32
    8
      src/Ad5001/Gitable/Windows.php

+ 1
- 1
src/Ad5001/Gitable/GitClient.php View File

@@ -82,7 +82,7 @@ abstract class GitClient {
public abstract function add($path) : string;


public abstract function diff($path) : string;
public abstract function diff() : string;


public abstract function status($path) : string;

+ 20
- 2
src/Ad5001/Gitable/Main.php View File

@@ -34,7 +34,7 @@ use pocketmine\Player;
class Main extends PluginBase implements Listener {
protected $git;

const PREFIX = C::BLACK . "[" . C::LIGHT_GRAY . "Git" . C::BLACK . "] " . C::LIGHT_GRAY;
const PREFIX = C::BLACK .C::BOLD . C::ITALIC . "[" . C::RESET . C::BOLD .C::GRAY . "Git" . C::BLACK . C::ITALIC . "] " . C::RESET . C::GRAY;


public function onEnable() {
@@ -69,7 +69,25 @@ class Main extends PluginBase implements Listener {

case "cd":
$this->git->cd($args[1]);
$sender->sendMessage("New path: " . $this->git->getDir());
$sender->sendMessage(self::PREFIX . "New path: " . $this->git->getDir());
break;

case "commit":
unset($args[0]);
$sender->sendMessage(self::PREFIX . $this->git->commit(implode(" ", $args)));
$sender->sendMessage(self::PREFIX . "Commited !");
break;

case "checkout":
$sender->sendMessage(self::PREFIX . $this->git->checkout($args[1]));
break;

case "dir":
$sender->sendMessage(self::PREFIX . $this->git->getDir());
break;

case "clone":
$sender->sendMessage(self::PREFIX . $this->git->clone($args[1]));
break;
}
return true;

+ 32
- 8
src/Ad5001/Gitable/Windows.php View File

@@ -27,17 +27,20 @@ class Windows extends GitClient {
public function commit(string $message) : string {
return shell_exec("git commit -m \"$message\"");
$handle = popen("git commit -m \"$message\"", 'r');
return fread($handle, 2096);
}
public function push(string $to = "github", string $from = "master") : string {
return shell_exec("git push $to $from");
$handle = popen("git push $to $from", 'r');
return fread($handle, 2096);
}
public function checkout($branch = null) : string {
return shell_exec("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch));
$handle = popen("git checkout " . (!is_null($branch) ? $this->getBranch() : $branch), 'r');
return fread($handle, 2096);
}
@@ -49,17 +52,20 @@ class Windows extends GitClient {
public function branch($branch = '') : string {
return shell_exec("git branch " . $branch);
$handle = popen("git branch " . $branch, 'r');
return fread($handle, 2096);
}
public function start() : string {
return shell_exec("git init");
$handle = popen("git init", 'r');
return fread($handle, 2096);
}
public function init() : string {
return shell_exec("git init");
$handle = popen("git init", 'r');
return fread($handle, 2096);
}
public function getDir() {
@@ -79,38 +85,56 @@ class Windows extends GitClient {
public function clone($from) : string {
$handle = popen("git clone $from", 'r');
return fread($handle, 2096);
}
public function log() : string {
$handle = popen("git log", 'r');
return fread($handle, 2096);
}
public function remove($path) : string {
$handle = popen("git rm $path", 'r');
return fread($handle, 2096);
}
public function move($path, $newpath) : string {
$handle = popen("git mv $path $newpath", 'r');
return fread($handle, 2096);
}
public function add($path) : string {
$handle = popen("git add $path", 'r');
return fread($handle, 2096);
}
public function diff($path) : string {
public function diff() : string {
$handle = popen("git diff $path", 'r');
return fread($handle, 2096);
}
public function status($path) : string {
public function status() : string {
$handle = popen("git status -s", 'r');
return fread($handle, 2096);
}
public function remote($name, $url) : string {
$handle = popen("git remote $name $url", 'r');
return fread($handle, 2096);
}
public function pull($to = "github", $from = "master") : string {
$handle = popen("git pull $to $from", 'r');
return fread($handle, 2096);
}

Loading…
Cancel
Save