import { Logger } from "../utils/logger" ; import { CheckInInfo } from "../entities/checkininfo" ; import { MessageConstants } from "../utils/messageconstants" ; import { CvsProviderProxy } from "../../dal/cvsproviderproxy" ; import { inject , injectable } from "inversify" ; import { ChangeListStatus , TYPES } from "../utils/constants" ; import { IResourceProvider } from "../../view/dataproviders/interfaces/iresourceprovider" ; import { IBuildProvider } from "../../view/dataproviders/interfaces/ibuildprovider" ; import { BuildConfig } from "../entities/buildconfig" ; import { IProviderManager } from "../../view/iprovidermanager" ; import { CustomPatchSender } from "../remoterun/patchsender" ; import { PatchManager } from "../utils/patchmanager" ; import { QueuedBuild } from "../utils/queuedbuild" ; import { WindowProxy } from "../moduleproxies/window-proxy" ; import { ShowMyChanges } from "./showmychanges" ; @ injectable ( ) export class RemoteRun implements Command { public constructor ( @ inject ( TYPES . CvsProviderProxy ) private readonly cvsProvider , @ inject ( TYPES . BuildProvider ) private readonly buildProvider , @ inject ( TYPES . ResourceProvider ) private readonly resourceProvider , @ inject ( TYPES . ProviderManager ) private readonly providerManager , @ inject ( TYPES . PatchSender ) private readonly patchSender , @ inject ( TYPES . PatchManager ) private readonly patchManager , @ inject ( TYPES . WindowProxy ) private readonly windowProxy , @ inject ( TYPES . ShowMyChangesCommand ) private readonly showMyChangesCommand ) { } public async exec ( args ? ) { if ( ! args || args . length !== 1 ) { Logger . logError ( "RemoteRun#exec: incorrect arguments" ) ; } const isPreTestedCommit = ! ! args [ 0 ] ; Logger . logInfo ( "RemoteRun#exec: Personal Build started" ) ; const buildConfigs = this . buildProvider . getSelectedContent ( ) ; const checkInArray = this . resourceProvider . getSelectedContent ( ) ; if ( ! buildConfigs || buildConfigs . length === 0 ) { return Promise . reject ( MessageConstants . NO_CONFIGS_RUN_REMOTERUN ) ; } const patchAbsPath = await this . patchManager . preparePatch ( checkInArray ) ; const message = await this . requestForCommitMessageIfRequired ( checkInArray ) ; this . fillCommitMessage ( checkInArray , message ) ; this . resourceProvider . resetTreeContent ( ) ; this . buildProvider . resetTreeContent ( ) ; this . providerManager . showChangesProvider ( ) ; this . showMyChangesCommand . exec ( [ true ] ) . then ( ( ) => { this . providerManager . refreshAll ( ) ; this . providerManager . showChangesProvider ( ) ; } ) ; const queuedBuilds = await this . patchSender . sendPatch ( buildConfigs , patchAbsPath , message ) ; const changeListStatus = await this . patchSender . waitForChangeFinish ( queuedBuilds ) ; if ( changeListStatus === ChangeListStatus . CHECKED ) { Logger . logInfo ( "RemoteRun#exec: Personal Build is successful" ) ; if ( isPreTestedCommit ) { return this . cvsProvider . requestForPostCommit ( checkInArray ) ; } } else { Logger . logWarning ( "RemoteRun#exec: Personal Build failed" ) ; return Promise . reject ( "Personal Build failed" ) ; } } private async requestForCommitMessageIfRequired ( checkInArray ) { let commitMessage ; if ( checkInArray . length > 0 ) { commitMessage = await this . windowProxy . showInputBox ( { prompt : MessageConstants . PROVIDE_MESSAGE_FOR_REMOTE_RUN } ) ; } return commitMessage || "" ; } private fillCommitMessage ( checkInArray , commitMessage ) { checkInArray . forEach ( ( checkInInfo ) => { checkInInfo . message = commitMessage ; } ) ; } }