@@ -104,21 +104,22 @@ let git = {
104104
105105 } ,
106106
107- 'getRepoPushAccess' : async ( treeLoc , loggedUser ) => {
107+ // check if user has push access in repository
108+ 'checkPushAccess' : async ( treeLoc , userToCheck ) => {
108109
109110 // map tree location
110111 let query = 'https://api.github.com' ;
111112 const [ user , repo ] = treeLoc ;
112113
113114 const [ repoName ] = repo . split ( ':' ) ;
114115
115- query += '/repos/' + user + '/' + repoName + '/collaborators/' + loggedUser + '/permission' ;
116+ query += '/repos/' + user + '/' + repoName + '/collaborators/' + userToCheck + '/permission' ;
116117
117118 // get the query
118119 const resp = await axios . get ( query , gitToken ) ;
119120
120121 if ( resp . message &&
121- resp . message === 'Must have push access to view collaborator permission.' ) {
122+ resp . message . startsWith ( 'Must have push access' ) ) {
122123
123124 return false ;
124125
@@ -216,20 +217,26 @@ let git = {
216217 } ,
217218
218219 // create a repository
219- 'createRepo' : async ( repoName ) => {
220+ 'createRepo' : async ( repoName , private ) => {
220221
221222 const query = 'https://api.github.com/user/repos' ;
222223
223224 const repoData = {
224225 name : repoName ,
225- private : true ,
226+ private : private ,
226227 has_wiki : false ,
227228 auto_init : true
228229 } ;
229230
231+ // change pushing state
232+ changePushingState ( true ) ;
233+
230234 // post the query
231235 const resp = await axios . post ( query , gitToken , repoData ) ;
232236
237+ // change pushing state
238+ changePushingState ( false ) ;
239+
233240 return resp . full_name ;
234241
235242 } ,
@@ -250,10 +257,16 @@ let git = {
250257 ref : 'refs/heads/' + newBranchName ,
251258 sha : shaToBranchFrom
252259 } ;
260+
261+ // change pushing state
262+ changePushingState ( true ) ;
253263
254264 // post the query
255265 const resp = await axios . post ( query , branchData , gitToken ) ;
256266
267+ // change pushing state
268+ changePushingState ( false ) ;
269+
257270 return resp ;
258271
259272 } ,
@@ -267,9 +280,15 @@ let git = {
267280 const query = 'https://api.github.com/repos' +
268281 '/' + user + '/' + repo + '/forks' ;
269282
283+ // change pushing state
284+ changePushingState ( true ) ;
285+
270286 // post the query
271287 const resp = await axios . post ( query , gitToken ) ;
272288
289+ // change pushing state
290+ changePushingState ( false ) ;
291+
273292 return resp . full_name ;
274293
275294 // change treeLoc to fork dir, change all the repo's modified files' dir to the fork's dir, and push modified files in dir.
@@ -286,13 +305,20 @@ let git = {
286305 '/' + user + '/' + repo +
287306 '/collaborators/' + usernameToInvite ;
288307
308+ // change pushing state
309+ changePushingState ( true ) ;
310+
289311 // put the query
290312 const resp = await axios . put ( query , gitToken ) ;
291313
314+ // change pushing state
315+ changePushingState ( false ) ;
316+
292317 return resp . node_id ;
293318
294319 } ,
295320
321+ // accept an invitation to a repository
296322 'acceptInviteToRepo' : async ( treeLoc ) => {
297323
298324 // map tree location
0 commit comments