Skip to content

Commit

Permalink
better error logging
Browse files Browse the repository at this point in the history
  • Loading branch information
WizardCM committed Oct 5, 2024
1 parent 2ae90d2 commit 1a3fe6d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
79 changes: 43 additions & 36 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -411,47 +411,54 @@ export async function createLocaleFile(languageList: Map<string, string>, 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 () => {
Expand Down

0 comments on commit 1a3fe6d

Please sign in to comment.