diff --git a/src/runWithOptions.test.ts b/src/runWithOptions.test.ts index 79b522ba..3e401770 100644 --- a/src/runWithOptions.test.ts +++ b/src/runWithOptions.test.ts @@ -7,6 +7,9 @@ import { BackportOptions } from './options/options'; import { commitsWithPullRequestsMock } from './services/github/mocks/commitsByAuthorMock'; import { runWithOptions } from './runWithOptions'; import * as childProcess from './services/child-process-promisified'; +import { PromiseReturnType } from './types/PromiseReturnType'; + +type ExecReturnType = PromiseReturnType; describe('runWithOptions', () => { let rpcExecMock: jest.SpyInstance; @@ -56,7 +59,7 @@ describe('runWithOptions', () => { rpcExecMock = jest .spyOn(childProcess, 'exec') - .mockResolvedValue({ stdout: 'success' } as any); + .mockResolvedValue({ stdout: 'success' } as ExecReturnType); rpcExecOriginalMock = jest.spyOn(childProcess, 'execAsCallback'); jest.spyOn(fs, 'writeFile').mockResolvedValue(undefined); diff --git a/src/services/child-process-promisified.ts b/src/services/child-process-promisified.ts index 522a5668..d6fc17a5 100644 --- a/src/services/child-process-promisified.ts +++ b/src/services/child-process-promisified.ts @@ -1,9 +1,6 @@ import child_process from 'child_process'; import { promisify } from 'util'; import { logger } from './logger'; -import { PromiseReturnType } from '../types/PromiseReturnType'; - -export type ExecReturnType = PromiseReturnType; export const exec = (cmd: string, options: child_process.ExecOptions = {}) => { logger.info(`exec: ${cmd}`); diff --git a/src/services/git.test.ts b/src/services/git.test.ts index 7a70514b..ea74b425 100644 --- a/src/services/git.test.ts +++ b/src/services/git.test.ts @@ -8,8 +8,9 @@ import { createFeatureBranch, } from '../services/git'; import * as childProcess from '../services/child-process-promisified'; +import { PromiseReturnType } from '../types/PromiseReturnType'; -type ExecReturnType = childProcess.ExecReturnType; +type ExecReturnType = PromiseReturnType; describe('getUnstagedFiles', () => { it('should split by linebreak and remove empty items', async () => { diff --git a/src/services/git.ts b/src/services/git.ts index 1c0cb6e1..fbf455d1 100644 --- a/src/services/git.ts +++ b/src/services/git.ts @@ -112,15 +112,15 @@ export async function cherrypickContinue(options: BackportOptions) { }); } catch (e) { const isCherrypickError = e.code === 128; - if (isCherrypickError) { - logger.info( - `Cherry pick continue failed. Probably because the cherry pick operation was manually completed. ${JSON.stringify( - e - )}` - ); - return; + if (!isCherrypickError) { + throw e; } - throw e; + + logger.info( + `Cherry pick continue failed. Probably because the cherry pick operation was manually completed. ${JSON.stringify( + e + )}` + ); } } diff --git a/src/ui/cherrypickAndCreatePullRequest.test.ts b/src/ui/cherrypickAndCreatePullRequest.test.ts index ae253d98..69335f4c 100644 --- a/src/ui/cherrypickAndCreatePullRequest.test.ts +++ b/src/ui/cherrypickAndCreatePullRequest.test.ts @@ -6,6 +6,9 @@ import * as childProcess from '../services/child-process-promisified'; import * as logger from '../services/logger'; import dedent from 'dedent'; import ora from 'ora'; +import { PromiseReturnType } from '../types/PromiseReturnType'; + +type ExecReturnType = PromiseReturnType; describe('cherrypickAndCreatePullRequest', () => { let axiosPostMock: jest.SpyInstance; @@ -35,7 +38,7 @@ describe('cherrypickAndCreatePullRequest', () => { beforeEach(async () => { execSpy = jest .spyOn(childProcess, 'exec') - .mockResolvedValue({ stdout: '' } as any); + .mockResolvedValue({ stdout: '' } as ExecReturnType); const options = { githubApiBaseUrlV3: 'https://api.github.com',