Files
jj-command-line/helpers/gitSubRepoUtils.ts
T
2024-11-13 18:18:14 -05:00

29 lines
921 B
TypeScript

import { bashRunAndReturnSync, bashRunAndShowLogsPromise } from "./bashUtils"
import { makeJJlogger } from "./jjLogger"
const logger = makeJJlogger({
filename: 'helpers/gitSubRepoUtils.ts'
})
export const subRepositoryClean = async (subRepoRelPath) => {
const repo = `${process.env.JJ_WORKSPACE_DIR}/${subRepoRelPath}`
logger.log(`clean repository ${repo} start`)
const command = `
pushd "${repo}" > /dev/null
git stash --include-untracked || true
git clean -f -X -e ".~envFormat" -e ".~jsonFormat" -e ".~shellFormat" || true
git clean -f -x -e ".~envFormat" -e ".~jsonFormat" -e ".~shellFormat" || true
git clean -xdf -e ".~envFormat" -e ".~jsonFormat" -e ".~shellFormat" || true
git reset --hard || true
popd > /dev/null
`
const res = await bashRunAndReturnSync({
command: command
})
logger.log(res)
logger.success(`clean repository ${repo} done`)
}