import { CpProxy } from "../../bll/moduleproxies/cp-proxy" ; import { Logger } from "../../bll/utils/logger" ; export class GetRemoteBranchName { constructor ( private readonly workspaceRootPath , private readonly gitPath , private readonly cpProxy ) { } public async execute ( ) { const theCommand = this . getCommand ( ) ; const commandResult = await this . cpProxy . execAsync ( theCommand ) ; if ( ! commandResult || ! commandResult . stdout || commandResult . stdout . length === 0 ) { Logger . logError ( `GetRemoteBranchName: remote branch wasn't determined` ) ; throw new Error ( "GitRemote branch wasn't determined" ) ; } const remoteBranch = commandResult . stdout . replace ( /'/g , "" ) . trim ( ) ; Logger . logDebug ( `GetRemoteBranchName: remote branch is ${ remoteBranch }` ) ; return remoteBranch ; } private getCommand ( ) { return `"${ this . gitPath }" -C "${ this . workspaceRootPath }" rev-parse --abbrev-ref --symbolic-full-name @{u}` ; } }