import { CvsResource } from "../../bll/entities/cvsresources/cvsresource" ; import { Logger } from "../../bll/utils/logger" ; import { CpProxy } from "../../bll/moduleproxies/cp-proxy" ; import { GitStatusRowsParser } from "./GitStatusRowsParser" ; export class GitStatusCommand { constructor ( private readonly workspaceRootPath , private readonly gitPath , private cpProxy , private readonly statusRowParser , private readonly isPorcelain = true ) { } public async execute ( ) { const END_SPACES_REGEXP = /\s*$/ ; let porcelainStatusResult ; porcelainStatusResult = await this . cpProxy . execAsync ( this . getCommand ( ) ) ; if ( ! porcelainStatusResult || ! porcelainStatusResult . stdout ) { Logger . logWarning ( `GitStatusCommand#exec: git status command result is empty` ) ; return [ ] ; } const statusRows = porcelainStatusResult . stdout . toString ( ) . replace ( END_SPACES_REGEXP , "" ) . split ( "\n" ) ; return this . statusRowParser . tryParseRows ( this . workspaceRootPath , statusRows ) ; } private getCommand ( ) { const builder = [ ] ; builder . push ( `"${ this . gitPath }"` ) ; builder . push ( `-C "${ this . workspaceRootPath }"` ) ; builder . push ( "status" ) ; builder . push ( `${ this . isPorcelain ? "--porcelain" : "" }` ) ; return builder . join ( " " ) ; } }