@@ -11,7 +11,12 @@ import {
1111 labelExistsOnPR ,
1212 removeLabel ,
1313} 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' ;
1520import { getEnvVar } from './utils/env-util' ;
1621import { PRChange , PRStatus , BackportPurpose , CheckRunStatus } from './enums' ;
1722import { Label } from '@octokit/webhooks-types' ;
@@ -28,15 +33,11 @@ import {
2833 updateBackportValidityCheck ,
2934} from './utils/checks-util' ;
3035import { 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.
4041delete globalThis . fetch ;
4142
4243const probotHandler : ApplicationFunction = async ( robot , { getRouter } ) => {
@@ -145,6 +146,12 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
145146 }
146147 } ;
147148
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+
148155 /**
149156 * Checks that a PR done to `main` contains the required
150157 * backport information, i.e.: at least a `no-backport` or
@@ -154,8 +161,6 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
154161 * @returns
155162 */
156163
157- const VALID_BACKPORT_CHECK_NAME = 'Valid Backport' ;
158-
159164 robot . on (
160165 [
161166 'pull_request.opened' ,
@@ -423,7 +428,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
423428 ) ;
424429
425430 // 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 ) => {
427432 const { pull_request : pr } = context . payload ;
428433
429434 const oldPRNumbers = getPRNumbersFromPRBody ( pr , true ) ;
@@ -471,7 +476,7 @@ const probotHandler: ApplicationFunction = async (robot, { getRouter }) => {
471476 const TROP_COMMAND_PREFIX = '/trop ' ;
472477
473478 // 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 ) => {
475480 const { issue, comment } = context . payload ;
476481
477482 const isPullRequest = ( i : { number : number ; html_url : string } ) =>
0 commit comments