This commit is contained in:
2024-11-13 18:54:43 -05:00
parent 3f42fd45e6
commit 1b190888db
3 changed files with 67 additions and 13 deletions
+1
View File
@@ -84,6 +84,7 @@ export async function bashRunAndShowLogsPromise({
if (!noError) {
reject()
}
resolve(data)
}
});
child.on('close', function (data) {
+59 -1
View File
@@ -1,3 +1,4 @@
import { setTimeout } from "timers/promises"
import { bashRunAndReturnSync, bashRunAndShowLogsPromise } from "./bashUtils"
import { makeJJlogger } from "./jjLogger"
@@ -26,4 +27,61 @@ popd > /dev/null
logger.log(res)
logger.success(`clean repository ${repo} done`)
}
return
}
export const subRepositoryPull = async (subRepoRelPath, branch, noLogger = false) => {
const repo = `${process.env.JJ_WORKSPACE_DIR}/${subRepoRelPath}`
if (!noLogger) {
logger.log(`pull repository ${repo} on ${branch} branch start`)
}
const command = `
pushd "${repo}" > /dev/null
git checkout ${branch} || true
git config pull.rebase false --replace-all || true
git pull origin || true
popd > /dev/null
`
const res = await bashRunAndReturnSync({
command: command
})
if (!noLogger) {
logger.log(res)
logger.success(`pull repository ${repo} on ${branch} branch done`)
}
return
}
export const subRepositoryPushChanges = async (subRepoRelPath, branch, commitMessage) => {
const repo = `${process.env.JJ_WORKSPACE_DIR}/${subRepoRelPath}`
logger.log(`push repository ${repo} on ${branch} branch "${commitMessage}" start`)
await subRepositoryPull(subRepoRelPath, branch)
await setTimeout(1000)
const command = `
pushd "${repo}" > /dev/null
git status || true
git add . || true
git status || true
git diff --cached --color | cat || true
git commit -m "${commitMessage}" || true
git push origin || true
popd > /dev/null
`
const res = await bashRunAndReturnSync({
command: command,
// noError: true
})
logger.log(res)
logger.success(`push repository ${repo} on ${branch} branch "${commitMessage}" done`)
return
}