1import { read2Resource } from './k8sF/read2ResourceF.mts'2import * as _ from 'lodash-es'3import { kubeResGitShaPath } from './k8sF/resGitShaPathF.mts'4import type { AppCfg } from './k8sF/ctxF/appCfgCtxF.mts'5import type { KubeResource } from './k8sF/ctxF/klusterCtxF.mts'6import { throwIf } from '../sharedF/throwErrorF/throwIfF.mts'7import { getAction } from './ctxF/actionCtxF.mts'8import { liveRepoExec } from './libF/gitF/gitRepoF.mts'9import { getManualRange } from './libF/gitF/getManualRangeF.mts'12 const {resourceTmpl, cluster_name} = appConfig15 if (!['info', 'diff', 'gitlog'].includes(action)) return appConfig17 const manualRange = getManualRange()18 if (manualRange) {19 appConfig.existingGitSha = (await liveRepoExec({cmd: `git rev-parse ${manualRange.from}`})).trim()20 return appConfig21 }23 if (!cluster_name) {24 if (action === 'gitlog') return appConfig25 appConfig.existingGitSha = (await liveRepoExec({cmd: 'git rev-parse HEAD~1'})).trim()26 return appConfig27 }29 const existingResource = await read2Resource({resource: resourceTmpl as KubeResource, cluster_name})31 Object.assign(appConfig, {existingGitSha: _.get(existingResource, kubeResGitShaPath)})33 return appConfig34}