10 defined(
'JPATH_PLATFORM') or die;
37 public function create($user, $repo, $message, $tree, array $parents = array())
40 $path =
'/repos/' . $user .
'/' . $repo .
'/git/commits';
43 array(
'message' => $message,
'tree' => $tree,
'parents' => $parents)
47 $response = $this->client->post($this->fetchUrl($path), $data);
50 if ($response->code != 201)
53 $error = json_decode($response->body);
54 throw new DomainException($error->message, $response->code);
57 return json_decode($response->body);
75 public function createCommitComment($user, $repo, $sha, $comment, $line, $filepath, $position)
78 $path =
'/repos/' . $user .
'/' . $repo .
'/commits/' . $sha .
'/comments';
84 'line' => (
int) $line,
86 'position' => (
int) $position
91 $response = $this->client->post($this->fetchUrl($path), $data);
94 if ($response->code != 201)
97 $error = json_decode($response->body);
98 throw new DomainException($error->message, $response->code);
101 return json_decode($response->body);
115 public function deleteCommitComment($user, $repo, $id)
118 $path =
'/repos/' . $user .
'/' . $repo .
'/comments/' . $id;
121 $response = $this->client->delete($this->fetchUrl($path));
124 if ($response->code != 204)
127 $error = json_decode($response->body);
128 throw new DomainException($error->message, $response->code);
131 return json_decode($response->body);
146 public function editCommitComment($user, $repo, $id, $comment)
149 $path =
'/repos/' . $user .
'/' . $repo .
'/comments/' . $id;
158 $response = $this->client->patch($this->fetchUrl($path), $data);
161 if ($response->code != 200)
164 $error = json_decode($response->body);
165 throw new DomainException($error->message, $response->code);
168 return json_decode($response->body);
184 public function getCommit($user, $repo, $sha, $page = 0, $limit = 0)
187 $path =
'/repos/' . $user .
'/' . $repo .
'/commits/' . $sha;
190 $response = $this->client->get($this->fetchUrl($path, $page, $limit));
193 if ($response->code != 200)
196 $error = json_decode($response->body);
197 throw new DomainException($error->message, $response->code);
200 return json_decode($response->body);
214 public function getCommitComment($user, $repo, $id)
217 $path =
'/repos/' . $user .
'/' . $repo .
'/comments/' . $id;
220 $response = $this->client->get($this->fetchUrl($path));
223 if ($response->code != 200)
226 $error = json_decode($response->body);
227 throw new DomainException($error->message, $response->code);
230 return json_decode($response->body);
246 public function getCommitComments($user, $repo, $sha, $page = 0, $limit = 0)
249 $path =
'/repos/' . $user .
'/' . $repo .
'/commits/' . $sha .
'/comments';
252 $response = $this->client->get($this->fetchUrl($path, $page, $limit));
255 if ($response->code != 200)
258 $error = json_decode($response->body);
259 throw new DomainException($error->message, $response->code);
262 return json_decode($response->body);
277 public function getDiff($user, $repo, $base, $head)
280 $path =
'/repos/' . $user .
'/' . $repo .
'/compare/' . $base .
'...' . $head;
283 $response = $this->client->get($this->fetchUrl($path));
286 if ($response->code != 200)
289 $error = json_decode($response->body);
290 throw new DomainException($error->message, $response->code);
293 return json_decode($response->body);
308 public function getList($user, $repo, $page = 0, $limit = 0)
311 $path =
'/repos/' . $user .
'/' . $repo .
'/commits';
314 $response = $this->client->get($this->fetchUrl($path, $page, $limit));
317 if ($response->code != 200)
320 $error = json_decode($response->body);
321 throw new DomainException($error->message, $response->code);
324 return json_decode($response->body);
339 public function getListComments($user, $repo, $page = 0, $limit = 0)
342 $path =
'/repos/' . $user .
'/' . $repo .
'/comments';
345 $response = $this->client->get($this->fetchUrl($path, $page, $limit));
348 if ($response->code != 200)
351 $error = json_decode($response->body);
352 throw new DomainException($error->message, $response->code);
355 return json_decode($response->body);