@@ -229,12 +229,19 @@ async function authoriseGitPush(id: string) {
229229 if ( isAxiosError ( error ) && error . response ) {
230230 switch ( error . response . status ) {
231231 case 401 :
232+ case 403 :
232233 console . error ( 'Error: Authorise: Authentication required' ) ;
233234 process . exitCode = 3 ;
234235 break ;
235236 case 404 :
236237 console . error ( `Error: Authorise: ID: '${ id } ': Not Found` ) ;
237238 process . exitCode = 4 ;
239+ break ;
240+ default :
241+ console . error (
242+ `Error: Authorise: '${ error . response . status } ': ${ error . response . data ?. message || error . message } ` ,
243+ ) ;
244+ process . exitCode = 5 ;
238245 }
239246 } else {
240247 handleErrorAndLog ( error , `Error: Authorise: '${ id } '` ) ;
@@ -247,7 +254,7 @@ async function authoriseGitPush(id: string) {
247254 * Reject git push by ID
248255 * @param {string } id The ID of the git push to reject
249256 */
250- async function rejectGitPush ( id : string ) {
257+ async function rejectGitPush ( id : string , reason : string ) {
251258 if ( ! fs . existsSync ( GIT_PROXY_COOKIE_FILE ) ) {
252259 console . error ( 'Error: Reject: Authentication required' ) ;
253260 process . exitCode = 1 ;
@@ -263,7 +270,7 @@ async function rejectGitPush(id: string) {
263270
264271 await axios . post (
265272 `${ baseUrl } /api/v1/push/${ id } /reject` ,
266- { } ,
273+ { reason } ,
267274 {
268275 headers : { Cookie : cookies } ,
269276 } ,
@@ -274,12 +281,19 @@ async function rejectGitPush(id: string) {
274281 if ( isAxiosError ( error ) && error . response ) {
275282 switch ( error . response . status ) {
276283 case 401 :
284+ case 403 :
277285 console . error ( 'Error: Reject: Authentication required' ) ;
278286 process . exitCode = 3 ;
279287 break ;
280288 case 404 :
281289 console . error ( `Error: Reject: ID: '${ id } ': Not Found` ) ;
282290 process . exitCode = 4 ;
291+ break ;
292+ default :
293+ console . error (
294+ `Error: Reject: '${ error . response . status } ': ${ error . response . data ?. message || error . message } ` ,
295+ ) ;
296+ process . exitCode = 5 ;
283297 }
284298 } else {
285299 handleErrorAndLog ( error , `Error: Reject: '${ id } '` ) ;
@@ -319,12 +333,19 @@ async function cancelGitPush(id: string) {
319333 if ( isAxiosError ( error ) && error . response ) {
320334 switch ( error . response . status ) {
321335 case 401 :
336+ case 403 :
322337 console . error ( 'Error: Cancel: Authentication required' ) ;
323338 process . exitCode = 3 ;
324339 break ;
325340 case 404 :
326341 console . error ( `Error: Cancel: ID: '${ id } ': Not Found` ) ;
327342 process . exitCode = 4 ;
343+ break ;
344+ default :
345+ console . error (
346+ `Error: Cancel: '${ error . response . status } ': ${ error . response . data ?. message || error . message } ` ,
347+ ) ;
348+ process . exitCode = 5 ;
328349 }
329350 } else {
330351 handleErrorAndLog ( error , `Error: Cancel: '${ id } '` ) ;
@@ -423,6 +444,7 @@ async function createUser(
423444 if ( isAxiosError ( error ) && error . response ) {
424445 switch ( error . response . status ) {
425446 case 401 :
447+ case 403 :
426448 console . error ( 'Error: Create User: Authentication required' ) ;
427449 process . exitCode = 3 ;
428450 break ;
@@ -563,9 +585,14 @@ yargs(hideBin(process.argv)) // eslint-disable-line @typescript-eslint/no-unused
563585 demandOption : true ,
564586 type : 'string' ,
565587 } ,
588+ reason : {
589+ describe : 'Reason for rejection' ,
590+ type : 'string' ,
591+ default : 'Rejected via GitProxy CLI' ,
592+ } ,
566593 } ,
567594 handler ( argv ) {
568- rejectGitPush ( argv . id ) ;
595+ rejectGitPush ( argv . id , argv . reason ) ;
569596 } ,
570597 } )
571598 . command ( {
0 commit comments