From 1a3fe6dd786fb0fba24a544ba28057df0b722bd4 Mon Sep 17 00:00:00 2001 From: Matt Gajownik Date: Sat, 5 Oct 2024 13:35:35 +1000 Subject: [PATCH] better error logging --- .github/workflows/build.yml | 2 +- src/download.ts | 79 ++++++++++++++++++++----------------- 2 files changed, 44 insertions(+), 37 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 536bbdf..cd83d51 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,7 +12,7 @@ jobs: - name: Build run: npm run build - name: Push - if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} + if: ${{ github.event_name == 'push' }} run: | git config --global user.email "<>" git config --global user.name "Build Bot" diff --git a/src/download.ts b/src/download.ts index ff74892..b4bafa8 100644 --- a/src/download.ts +++ b/src/download.ts @@ -411,47 +411,54 @@ export async function createLocaleFile(languageList: Map, langua * @param submodules A list of submodules. */ function pushChanges(detachedSubmodules: string[], submodules: string[]): void { - if (process.env.CROWDIN_SYNC_SKIP_PUSH) { - return; - } - exec(`git config --global user.name '${STRINGS.git.committer.name}'`); - exec(`git config --global user.email '${STRINGS.git.committer.email}'`); - for (const submodule of submodules) { - process.chdir(`plugins/${submodule}`); - if (exec('git status --porcelain').length === 0) { + ACTIONS.info("WIZARDCM DEBUG - Running PushChanges."); + try { + if (process.env.CROWDIN_SYNC_SKIP_PUSH) { + return; + } + exec(`git config --global user.name '${STRINGS.git.committer.name}'`); + exec(`git config --global user.email '${STRINGS.git.committer.email}'`); + for (const submodule of submodules) { + process.chdir(`plugins/${submodule}`); + if (exec('git status --porcelain').length === 0) { + process.chdir('../..'); + continue; + } + exec('git add data/locale/*-*.ini'); + exec(`git commit -m '${STRINGS.git.commitTitle}'`); + exec('git push'); process.chdir('../..'); - continue; } - exec('git add data/locale/*-*.ini'); + for (const allowedPath of [ + 'AUTHORS', + 'plugins/*/data/locale/*-*.ini', + 'plugins/mac-virtualcam/src/obs-plugin/data/locale/*-*.ini', + 'UI/data/locale.ini', + 'UI/data/locale/*-*.ini', + 'UI/cmake/linux/com.obsproject.Studio.desktop', + 'UI/frontend-plugins/*/data/locale/*-*.ini' + ]) { + ACTIONS.info(exec(`git add '${allowedPath}'`)); + } + for (const submodule of submodules) { + exec(`git add plugins/${submodule}`); + } + for (const submodule of detachedSubmodules) { + ACTIONS.info(`${submodule} has commits not pushed to the main repository. Only pushing to submodule.`); + exec(`git checkout HEAD -- plugins/${submodule}`); + exec(`git submodule update --init plugins/${submodule}`); + } + if (exec('git status --porcelain').length === 0) { + ACTIONS.info('No changes in main repository. Skipping push.'); + return; + } + ACTIONS.info(exec('git log --staged')); exec(`git commit -m '${STRINGS.git.commitTitle}'`); exec('git push'); - process.chdir('../..'); - } - for (const allowedPath of [ - 'AUTHORS', - 'plugins/*/data/locale/*-*.ini', - 'plugins/mac-virtualcam/src/obs-plugin/data/locale/*-*.ini', - 'UI/data/locale.ini', - 'UI/data/locale/*-*.ini', - 'UI/cmake/linux/com.obsproject.Studio.desktop', - 'UI/frontend-plugins/*/data/locale/*-*.ini' - ]) { - exec(`git add '${allowedPath}'`); - } - for (const submodule of submodules) { - exec(`git add plugins/${submodule}`); - } - for (const submodule of detachedSubmodules) { - ACTIONS.info(`${submodule} has commits not pushed to the main repository. Only pushing to submodule.`); - exec(`git checkout HEAD -- plugins/${submodule}`); - exec(`git submodule update --init plugins/${submodule}`); - } - if (exec('git status --porcelain').length === 0) { - ACTIONS.info('No changes in main repository. Skipping push.'); - return; + } catch (e) { + ACTIONS.info("WIZARDCM DEBUG - Failed PushChanges."); + ACTIONS.setFailed(e as Error); } - exec(`git commit -m '${STRINGS.git.commitTitle}'`); - exec('git push'); } (async () => {