Browse Source

Added migration to repo. Added params methods to Lib\Client to create a standard for each Base class

Joachim M. Giæver 6 years ago
parent
commit
35629e25db
2 changed files with 19 additions and 2 deletions
  1. 3 2
      index.php
  2. 16 0
      src/API/Request/Repo.php

+ 3 - 2
index.php

@@ -133,8 +133,9 @@ try {
 
 
     echo "\nMigrate repo 'gogs-php-api-client.git'\n";
-    $mrepo = $repos->create();
-    $mrepo->migrate("https://git.giaever.org/joachimmg/gogs-php-api-client.git", "gogs-php-api-client-migrate");
+    $mrepo = $repos->create()->migrate("https://git.giaever.org/joachimmg/gogs-php-api-client.git", "gogs-php-api-client-migrate");
+    echo "Syncing repository '" . $mrepo->full_name . "'\n";
+    $mrepo->sync();
     echo sprintf("Delete migrated repo: %s\n", $mrepo->delete());
 
     // Load all of my organizations.

+ 16 - 0
src/API/Request/Repo.php

@@ -222,6 +222,22 @@ namespace Gogs\API\Request {
 
             return $this;
         }
+
+        /** 
+         * Add repo to sync queue. 
+         *
+         * Requires the repository to be a mirror.
+         * 
+         * @return bool
+         */
+        public function sync() {
+            if ($this->mirror) {
+                $this->set_scope("mirror_sync");
+                $this->method_post();
+                return true;
+            }
+            return false;
+        }
     }
 
 }