|
@@ -65,7 +65,7 @@ namespace Gogs\API\Request {
|
|
|
protected function set_scope(string $method) {
|
|
|
switch ($method) {
|
|
|
case "create":
|
|
|
- if (!$this->owner->authenticated() && empty($this->owner->username))
|
|
|
+ if (empty($this->owner) || !$this->owner->authenticated() && empty($this->owner->username))
|
|
|
throw new Exception\RequestErrorException("Missing userdata of unauthorized user 'username'");
|
|
|
|
|
|
if ($this->owner instanceof Org)
|
|
@@ -76,14 +76,14 @@ namespace Gogs\API\Request {
|
|
|
$this->scope = "/admin/users/" . $this->owner->username . "/repos";
|
|
|
break;
|
|
|
case "delete":
|
|
|
- if (empty($this->owner->username))
|
|
|
+ if (empty($this->owner) || empty($this->owner->username))
|
|
|
throw new Exception\RequestErrorException("Missing userdata 'username'");
|
|
|
|
|
|
$this->scope = "/repos/" . $this->owner->username . "/" . $this->name;
|
|
|
break;
|
|
|
case "get":
|
|
|
case "load":
|
|
|
- if (empty($this->owner->username) && empty($this->full_name))
|
|
|
+ if ((empty($this->owner) || empty($this->owner->username)) && empty($this->full_name))
|
|
|
throw new Exception\RequestErrorException("Missing userdata 'username' and/or 'full_name'");
|
|
|
|
|
|
$this->scope = "/repos/" . ($this->owner ? $this->owner->username . "/" . $this->name : $this->full_name);
|
|
@@ -91,6 +91,12 @@ namespace Gogs\API\Request {
|
|
|
case "migrate":
|
|
|
$this->scope = "/repos/migrate";
|
|
|
break;
|
|
|
+ case "sync":
|
|
|
+ if (empty($this->owner) || empty($this->owner->username))
|
|
|
+ throw new Exception\RequestErrorException("Missing userdata 'username'");
|
|
|
+
|
|
|
+ $this->scope = sprintf("/repos/%s/%s/mirror-sync", $this->owner->username, $this->name);
|
|
|
+ break;
|
|
|
default:
|
|
|
return false;
|
|
|
}
|
|
@@ -232,7 +238,7 @@ namespace Gogs\API\Request {
|
|
|
*/
|
|
|
public function sync() {
|
|
|
if ($this->mirror) {
|
|
|
- $this->set_scope("mirror_sync");
|
|
|
+ $this->set_scope("sync");
|
|
|
$this->method_post();
|
|
|
return true;
|
|
|
}
|