/** * @module reset-cmd * * Isomorphic execution engine for `vcs reset [path...]`. * Unstages specified files (or all files) from active branch galaxy. */ import { extractErrorMsg } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs'; import { GLOBAL_LOG_A_LOT } from '../../../core-constants.mjs'; import { unstagePathsFromGalaxy } from '../b2tfs-galaxy/b2tfs-galaxy-helpers.mjs'; import { VcsResetOpts, VcsResetResult } from './command-types.mjs'; const lcFile = `[reset-cmd]`; const logalot = GLOBAL_LOG_A_LOT; export async function executeVcsReset({ metaspace, localSpace, activeBranchSpace, galaxyIbGib, paths = [], all = false, targetDir = '', activeWorktreeDir, }: VcsResetOpts): Promise { const lc = `${lcFile}[${executeVcsReset.name}]`; try { if (logalot) { console.log(`${lc} starting... (I: 9c70a86e0b28bd8a9862230e17379126)`); } const targetGalaxySpace = localSpace || activeBranchSpace; const unstageRes = await unstagePathsFromGalaxy({ galaxyIbGib, paths, targetDir, activeWorktreeDir, space: targetGalaxySpace, metaspace, all, }); const finalStagedCount = Object.keys(unstageRes.updatedGalaxy.data?.stagedPaths || {}).length; return { unstagedPaths: unstageRes.unstagedPaths, stagedCount: finalStagedCount, updatedGalaxy: unstageRes.updatedGalaxy, }; } catch (error) { console.error(`${lc} ${extractErrorMsg(error)} (E: aade98ceb7b3677f68ef666822ce7826)`); throw error; } finally { if (logalot) { console.log(`${lc} complete. (I: 8f0b1890b1380b24184544b89a12d126)`); } } }