@@ -11,7 +11,12 @@ import {
11
11
labelExistsOnPR ,
12
12
removeLabel ,
13
13
} from './utils/label-utils' ;
14
- import { CHECK_PREFIX , NO_BACKPORT_LABEL , SKIP_CHECK_LABEL } from './constants' ;
14
+ import {
15
+ CHECK_PREFIX ,
16
+ NO_BACKPORT_LABEL ,
17
+ SKIP_CHECK_LABEL ,
18
+ VALID_BACKPORT_CHECK_NAME ,
19
+ } from './constants' ;
15
20
import { getEnvVar } from './utils/env-util' ;
16
21
import { PRChange , PRStatus , BackportPurpose , CheckRunStatus } from './enums' ;
17
22
import { Label } from '@octokit/webhooks-types' ;
@@ -28,15 +33,11 @@ import {
28
33
updateBackportValidityCheck ,
29
34
} from './utils/checks-util' ;
30
35
import { register } from './utils/prom' ;
31
- import {
32
- SimpleWebHookRepoContext ,
33
- WebHookIssueContext ,
34
- WebHookPR ,
35
- WebHookPRContext ,
36
- } from './types' ;
37
-
38
- // Built in fetch doesn't support global-agent...
39
- // @ts -ignore
36
+ import { SimpleWebHookRepoContext , WebHookPR , WebHookPRContext } from './types' ;
37
+
38
+ import { execSync } from 'child_process' ;
39
+
40
+ // @ts -ignore - builtin fetch doesn't support global-agent.
40
41
delete globalThis . fetch ;
41
42
42
43
const probotHandler : ApplicationFunction = async ( robot , { getRouter } ) => {
@@ -145,6 +146,12 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
145
146
}
146
147
} ;
147
148
149
+ const gitExists = execSync ( 'which git' ) . toString ( ) . trim ( ) ;
150
+ if ( / g i t n o t f o u n d / . test ( gitExists ) ) {
151
+ robot . log ( 'Git not found - unable to proceed with backporting' ) ;
152
+ process . exit ( 1 ) ;
153
+ }
154
+
148
155
/**
149
156
* Checks that a PR done to `main` contains the required
150
157
* backport information, i.e.: at least a `no-backport` or
@@ -154,8 +161,6 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
154
161
* @returns
155
162
*/
156
163
157
- const VALID_BACKPORT_CHECK_NAME = 'Valid Backport' ;
158
-
159
164
robot . on (
160
165
[
161
166
'pull_request.opened' ,
@@ -423,7 +428,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
423
428
) ;
424
429
425
430
// Backport pull requests to labeled targets when PR is merged.
426
- robot . on ( 'pull_request.closed' , async ( context : WebHookPRContext ) => {
431
+ robot . on ( 'pull_request.closed' , async ( context ) => {
427
432
const { pull_request : pr } = context . payload ;
428
433
429
434
const oldPRNumbers = getPRNumbersFromPRBody ( pr , true ) ;
@@ -471,7 +476,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
471
476
const TROP_COMMAND_PREFIX = '/trop ' ;
472
477
473
478
// Manually trigger backporting process on trigger comment phrase.
474
- robot . on ( 'issue_comment.created' , async ( context : WebHookIssueContext ) => {
479
+ robot . on ( 'issue_comment.created' , async ( context ) => {
475
480
const { issue, comment } = context . payload ;
476
481
477
482
const isPullRequest = ( i : { number : number ; html_url : string } ) =>
0 commit comments