@@ -23,6 +23,7 @@ class Repo extends Api
23
23
*/
24
24
public function search ($ query , $ language = '' , $ startPage = 1 )
25
25
{
26
+ //todo old api
26
27
$ response = $ this ->get ('repos/search/ ' .urlencode ($ query ), array (
27
28
'language ' => strtolower ($ language ),
28
29
'start_page ' => $ startPage
@@ -43,18 +44,6 @@ public function getUserRepos($username)
43
44
return $ this ->get ('users/ ' .urlencode ($ username ).'/repos ' );
44
45
}
45
46
46
- /**
47
- * Get a list of the repositories that the authenticated user can push to
48
- *
49
- * @return array list of repositories
50
- */
51
- public function getPushableRepos ()
52
- {
53
- $ response = $ this ->get ('repos/pushable ' );
54
-
55
- return $ response ['repositories ' ];
56
- }
57
-
58
47
/**
59
48
* Get extended information about a repository by its username and repo name
60
49
*
@@ -69,7 +58,6 @@ public function show($username, $repo)
69
58
70
59
/**
71
60
* create repo
72
- * http://develop.github.com/p/repo.html
73
61
*
74
62
* @param string $name name of the repository
75
63
* @param string $description repo description
@@ -79,19 +67,16 @@ public function show($username, $repo)
79
67
*/
80
68
public function create ($ name , $ description = '' , $ homepage = '' , $ public = true )
81
69
{
82
- $ response = $ this ->post ('repos/create ' , array (
70
+ return $ this ->post ('user/repos ' , array (
83
71
'name ' => $ name ,
84
72
'description ' => $ description ,
85
73
'homepage ' => $ homepage ,
86
- 'public ' => $ public
74
+ 'private ' => ! $ public
87
75
));
88
-
89
- return $ response ['repository ' ];
90
76
}
91
77
92
78
/**
93
79
* delete repo
94
- * http://develop.github.com/p/repo.html
95
80
*
96
81
* @param string $name name of the repository
97
82
* @param string $token delete token
@@ -101,6 +86,7 @@ public function create($name, $description = '', $homepage = '', $public = true)
101
86
*/
102
87
public function delete ($ name , $ token = null , $ force = false )
103
88
{
89
+ //todo old api
104
90
if ($ token === null ) {
105
91
$ response = $ this ->post ('repos/delete/ ' .urlencode ($ name ));
106
92
@@ -120,7 +106,6 @@ public function delete($name, $token = null, $force = false)
120
106
121
107
/**
122
108
* Set information of a repository
123
- * http://develop.github.com/p/repo.html
124
109
*
125
110
* @param string $username the user who owns the repo
126
111
* @param string $repo the name of the repo
@@ -129,89 +114,77 @@ public function delete($name, $token = null, $force = false)
129
114
*/
130
115
public function setRepoInfo ($ username , $ repo , $ values )
131
116
{
132
- $ response = $ this ->post ('repos/show/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ), array ('values ' => $ values ));
133
-
134
- return $ response ['repository ' ];
117
+ return $ this ->patch ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ), $ values );
135
118
}
136
119
137
120
/**
138
121
* Set the visibility of a repostory to public
139
- * http://develop.github.com/p/repo.html
140
122
*
123
+ * @param string $username the user who owns the repo
141
124
* @param string $repo the name of the repo
142
125
* @return array informations about the repo
143
126
*/
144
- public function setPublic ($ repo )
127
+ public function setPublic ($ username , $ repo )
145
128
{
146
- $ response = $ this ->get ('repos/set/public/ ' .urlencode ($ repo ));
147
-
148
- return $ response ['repository ' ];
129
+ $ this ->setRepoInfo ($ username , $ repo , array ('private ' => false ));
149
130
}
150
131
151
132
/**
152
133
* Set the visibility of a repostory to private
153
- * http://develop.github.com/p/repo.html
154
134
*
135
+ * @param string $username the user who owns the repo
155
136
* @param string $repo the name of the repo
156
137
* @return array informations about the repo
157
138
*/
158
- public function setPrivate ($ repo )
139
+ public function setPrivate ($ username , $ repo )
159
140
{
160
- $ response = $ this ->get ('repos/set/private/ ' .urlencode ($ repo ));
161
-
162
- return $ response ['repository ' ];
141
+ $ this ->setRepoInfo ($ username , $ repo , array ('private ' => true ));
163
142
}
164
143
165
144
/**
166
145
* Get the list of deploy keys for a repository
167
146
*
147
+ * @param string $username the user who owns the repo
168
148
* @param string $repo the name of the repo
169
149
* @return array the list of deploy keys
170
150
*/
171
- public function getDeployKeys ($ repo )
151
+ public function getDeployKeys ($ username , $ repo )
172
152
{
173
- $ response = $ this ->get ('repos/keys/ ' .urlencode ($ repo ));
174
-
175
- return $ response ['public_keys ' ];
153
+ return $ this ->get ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/keys ' );
176
154
}
177
155
178
156
/**
179
157
* Add a deploy key for a repository
180
158
*
159
+ * @param string $username the user who owns the repo
181
160
* @param string $repo the name of the repo
182
161
* @param string $title the title of the key
183
162
* @param string $key the public key data
184
163
* @return array the list of deploy keys
185
164
*/
186
- public function addDeployKey ($ repo , $ title , $ key )
165
+ public function addDeployKey ($ username , $ repo , $ title , $ key )
187
166
{
188
- $ response = $ this ->post ('repos/key / ' .urlencode ($ repo ).'/add ' , array (
167
+ return $ this ->post ('repos/ ' . urlencode ( $ username ). ' / ' .urlencode ($ repo ).'/keys ' , array (
189
168
'title ' => $ title ,
190
169
'key ' => $ key
191
170
));
192
-
193
- return $ response ['public_keys ' ];
194
171
}
195
172
196
173
/**
197
174
* Delete a deploy key from a repository
198
175
*
176
+ * @param string $username the user who owns the repo
199
177
* @param string $repo the name of the repo
200
178
* @param string $id the the id of the key to remove
201
179
* @return array the list of deploy keys
202
180
*/
203
- public function removeDeployKey ($ repo , $ id )
181
+ public function removeDeployKey ($ username , $ repo , $ id )
204
182
{
205
- $ response = $ this ->post ('repos/key/ ' .urlencode ($ repo ).'/remove ' , array (
206
- 'id ' => $ id ,
207
- ));
208
-
209
- return $ response ['public_keys ' ];
183
+ return $ this ->post ('repos/ ' .urlencode ($ username ).'/ ' .urlencode ($ repo ).'/keys/ ' .urlencode ($ id ));
210
184
}
211
185
212
186
/**
213
187
* Get the collaborators of a repository
214
- * http://develop.github.com/p/repo.html
215
188
*
216
189
* @param string $username the user who owns the repo
217
190
* @param string $repo the name of the repo
0 commit comments