summaryrefslogtreecommitdiff
path: root/src/GitModule.php
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2021-04-20 12:44:20 +0200
committerDaniel Weipert <code@drogueronin.de>2021-04-20 12:44:20 +0200
commit11dc8c730dda2c5bd38cb386f96331c5ce3cac9c (patch)
treeb2c03112114af00e33ce8e1276194906064fcf93 /src/GitModule.php
parentd4d5ae3bb6566311b2d42cf888e463b62f6cf0dc (diff)
Adds a bunch of new Modules
Diffstat (limited to 'src/GitModule.php')
-rw-r--r--src/GitModule.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/GitModule.php b/src/GitModule.php
new file mode 100644
index 0000000..3927992
--- /dev/null
+++ b/src/GitModule.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace PHPIAC\Modules;
+
+use PHPIAC\Connection;
+use PHPIAC\Module\Module;
+use PHPIAC\Modules\Support\HasPermissions;
+
+class GitModule extends Module
+{
+ use HasPermissions;
+
+ protected string $repo;
+ protected string $dest;
+
+ /**
+ * @inheritDoc
+ */
+ public function checkState(): bool
+ {
+ Connection::enablePty();
+
+ Connection::exec("ls $this->dest");
+ $ls = Connection::read();
+
+ $state = ! str_contains($ls, 'No such file or directory');
+
+ Connection::disablePty();
+
+ return $state;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function getCommands(): array
+ {
+ Connection::exec(
+ "sudo git clone $this->repo $this->dest" . PHP_EOL .
+ $this->getPermissions($this->dest)
+ );
+
+ return [];
+ }
+}