Pocketmine Git client !
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

Windows.php 3.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. <?php
  2. namespace Ad5001\Gitable;
  3. use pocketmine\Server;
  4. use pocketmine\Player;
  5. use Ad5001\Gitable\Main;
  6. class Windows extends GitClient {
  7. public function commit(string $message) : string {
  8. $handle = popen($this->getDataFolder() . "bin/git.exe commit -m \"$message\"", 'r');
  9. return fread($handle, 2096);
  10. }
  11. public function push(string $to ="github", string $from = "master") : string {
  12. $handle = popen($this->getDataFolder() . "bin/git.exe push $to $from", 'r');
  13. return fread($handle, 2096);
  14. }
  15. public function checkout($branch = null) : string {
  16. $handle = popen($this->getDataFolder() . "bin/git.exe checkout " . (!is_null($branch) ? $this->getBranch() : $branch), 'r');
  17. return fread($handle, 2096);
  18. }
  19. public function getBranch() : string {
  20. $handle = popen($this->getDataFolder() . "bin/git.exe branch", 'r');
  21. $read = fread($handle, 2096);
  22. return explode(" ", $read)[1];
  23. }
  24. public function branch($branch = '') : string {
  25. $handle = popen($this->getDataFolder() . "bin/git.exe branch " . $branch, 'r');
  26. return fread($handle, 2096);
  27. }
  28. public function start() : string {
  29. $handle = popen($this->getDataFolder() . "bin/git.exe init", 'r');
  30. return fread($handle, 2096);
  31. }
  32. public function init() : string {
  33. $handle = popen($this->getDataFolder() . "bin/git.exe init", 'r');
  34. return fread($handle, 2096);
  35. }
  36. public function getDir() {
  37. return $this->dir;
  38. }
  39. public function cd($path) : string {
  40. if(is_dir($path)) {
  41. $dir = chdir($path);
  42. $this->dir = getcwd();
  43. return (string) $dir;
  44. } else {
  45. return "Directory $path not found !";
  46. }
  47. }
  48. public function clone($from) : string {
  49. $handle = popen($this->getDataFolder() . "bin/git.exe clone $from", 'r');
  50. return fread($handle, 2096);
  51. }
  52. public function log() : string {
  53. $handle = popen($this->getDataFolder() . "bin/git.exe log", 'r');
  54. return fread($handle, 2096);
  55. }
  56. public function remove($path) : string {
  57. $handle = popen($this->getDataFolder() . "bin/git.exe rm $path", 'r');
  58. return fread($handle, 2096);
  59. }
  60. public function move($path, $newpath) : string {
  61. $handle = popen($this->getDataFolder() . "bin/git.exe mv $path $newpath", 'r');
  62. return fread($handle, 2096);
  63. }
  64. public function add($path) : string {
  65. $handle = popen($this->getDataFolder() . "bin/git.exe add $path", 'r');
  66. return fread($handle, 2096);
  67. }
  68. public function diff() : string {
  69. $handle = popen($this->getDataFolder() . "bin/git.exe diff $path", 'r');
  70. return fread($handle, 2096);
  71. }
  72. public function status() : string {
  73. $handle = popen($this->getDataFolder() . "bin/git.exe status -s", 'r');
  74. return fread($handle, 2096);
  75. }
  76. public function remote($name, $url) : string {
  77. $handle = popen($this->getDataFolder() . "bin/git.exe remote $name $url", 'r');
  78. return fread($handle, 2096);
  79. }
  80. public function pull($to = "github", $from = "master") : string {
  81. $handle = popen($this->getDataFolder() . "bin/git.exe pull $to $from", 'r');
  82. return fread($handle, 2096);
  83. }
  84. }