Skip to content

Commit d394c61

Browse files
committed
Added support for:
GET /projects/starred GET /projects/:id/repository/commits/:sha/statuses POST /projects/:id/statuses/:sha
1 parent db1e299 commit d394c61

File tree

2 files changed

+81
-14
lines changed

2 files changed

+81
-14
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,31 @@ public function owned($page = 1, $per_page = self::PER_PAGE, $order_by = self::O
5656
));
5757
}
5858

59+
/**
60+
* Get a list of projects which are starred by the authenticated user.
61+
*
62+
* @param int $page Page number
63+
* @param int $per_page Number of starred projects per page
64+
* @param null $archived if passed, limit by archived status
65+
* @param null $visibility if passed, limit by visibility public, internal, private
66+
* @param string $order_by Return requests ordered by id, name, path, created_at, updated_at or last_activity_at fields. Default is created_at
67+
* @param string $sort Return requests sorted in asc or desc order. Default is desc
68+
* @param null $search Return list of authorized projects according to a search criteria
69+
* @return mixed
70+
*/
71+
public function starred($page = 1, $per_page = self::PER_PAGE, $archived = null, $visibility = null, $order_by = self::ORDER_BY, $sort = self::SORT, $search = null)
72+
{
73+
return $this->get('projects/starred', array(
74+
'page' => $page,
75+
'per_page' => $per_page,
76+
'archived' => $archived,
77+
'visibility' => $visibility,
78+
'order_by' => $order_by,
79+
'sort' => $sort,
80+
'search' => $search
81+
));
82+
}
83+
5984
/**
6085
* @param string $query
6186
* @param int $page
@@ -417,4 +442,20 @@ public function removeService($project_id, $service_name)
417442
{
418443
return $this->delete($this->getProjectPath($project_id, 'services/'.$this->encodePath($service_name)));
419444
}
445+
446+
/**
447+
* @param $project_id
448+
* @param $sha
449+
* @param $state The state of the status. Can be one of the following: pending, running, success, failed, canceled
450+
* @param array $params name or context (string) = The label to differentiate this status from the status of other systems. Default value is default
451+
* target_url (string) = The target URL to associate with this status
452+
* description (string) = The short description of the status
453+
* @return mixed
454+
*/
455+
public function createStatus($project_id, $sha, $state, array $params = array())
456+
{
457+
$params['state'] = $state;
458+
return $this->post($this->getProjectPath($project_id, 'statuses/'.$this->encodePath($sha)), $params);
459+
}
460+
420461
}

lib/Gitlab/Api/Repositories.php

Lines changed: 40 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -134,20 +134,46 @@ public function commit($project_id, $sha)
134134
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha)));
135135
}
136136

137-
/**
138-
* @param int $project_id
139-
* @param string $sha
140-
* @param int $page
141-
* @param int $per_page
142-
* @return mixed
143-
*/
144-
public function commitComments($project_id, $sha, $page = 0, $per_page = self::PER_PAGE)
145-
{
146-
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/comments'), array(
147-
'page' => $page,
148-
'per_page' => $per_page
149-
));
150-
}
137+
/**
138+
* Get the statuses of a commit in a project.
139+
*
140+
* @since GitLab 8.1
141+
*
142+
* @param $project_id
143+
* @param $sha
144+
* @param int $page
145+
* @param int $per_page
146+
* @param null $ref_name The name of a repository branch or tag or, if not given, the default branch
147+
* @param null $stage Filter by build stage, e.g., test
148+
* @param null $name Filter by job name, e.g., bundler:audit
149+
* @param bool $all Return all statuses, not only the latest ones
150+
* @return mixed
151+
*/
152+
public function commitStatuses( $project_id, $sha, $page = 0, $per_page = self::PER_PAGE, $ref_name = null, $stage = null, $name = null, $all = false ) {
153+
return $this->get( $this->getProjectPath( $project_id, 'repository/commits/' . $this->encodePath( $sha ) . '/statuses' ), array(
154+
'page' => $page,
155+
'per_page' => $per_page,
156+
'ref_name' => $ref_name,
157+
'stage' => $stage,
158+
'name' => $name,
159+
'all' => $all
160+
) );
161+
}
162+
163+
/**
164+
* @param int $project_id
165+
* @param string $sha
166+
* @param int $page
167+
* @param int $per_page
168+
* @return mixed
169+
*/
170+
public function commitComments($project_id, $sha, $page = 0, $per_page = self::PER_PAGE)
171+
{
172+
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/comments'), array(
173+
'page' => $page,
174+
'per_page' => $per_page
175+
));
176+
}
151177

152178
/**
153179
* @param int $project_id

0 commit comments

Comments
 (0)