import { CpProxy } from "../../bll/moduleproxies/cp-proxy" ; import { GetRemoteBranchName } from "./GetRemoteBranchName" ; import { Logger } from "../../bll/utils/logger" ; export class GetLastCompatibleMergeBaseRev { constructor ( private readonly workspaceRootPath , private readonly gitPath , private readonly cpProxy , private readonly getRemoteBranchName ) { } public async execute ( ) { const remoteBranch = await this . getRemoteBranchName . execute ( ) ; const theCommand = this . getCommand ( remoteBranch ) ; const result = await this . cpProxy . execAsync ( theCommand ) ; if ( ! result || ! result . stdout || result . stdout . length === 0 ) { Logger . logError ( `GetLastCompatibleMergeBaseRevision: revision of last commit wasn't determined` ) ; throw new Error ( "Revision of last commit wasn't determined." ) ; } const lastRevHash = result . stdout . trim ( ) ; Logger . logDebug ( `GetLastCompatibleMergeBaseRevision: last merge-based revision is ${ lastRevHash }` ) ; return lastRevHash ; } private getCommand ( remoteBranch ) { return `"${ this . gitPath }" -C "${ this . workspaceRootPath }" merge-base HEAD ${ remoteBranch }` ; } }