Fixed logs

This commit is contained in:
2024-12-29 00:29:24 +01:00
parent c3122a8d72
commit 176b6de578
2 changed files with 17 additions and 19 deletions

26
app.ts
View File

@@ -1,7 +1,7 @@
import {spawn} from "child_process"; import { spawn } from "child_process";
import {ChildProcess, SpawnOptions} from "node:child_process"; import { ChildProcess, SpawnOptions } from "node:child_process";
import * as core from '@actions/core'; import * as core from '@actions/core';
import {LogLevel, writeConsole} from "@skydust/toolkit"; import { LogLevel, writeConsole } from "@skydust/toolkit";
// Ignored branches // Ignored branches
const IGNORED_BRANCHES: string[] = core.getInput('branchesToIgnore', { required: false }).split(","); const IGNORED_BRANCHES: string[] = core.getInput('branchesToIgnore', { required: false }).split(",");
@@ -46,7 +46,6 @@ const runGitCommand = (args: string[], options?: SpawnOptions): Promise<string>
}); });
} }
/** /**
* Fetch all remote branches. * Fetch all remote branches.
*/ */
@@ -90,18 +89,17 @@ const buildRebaseDependencyGraph = async (branches: string[]): Promise<Record<st
for (const branchA of branches) { for (const branchA of branches) {
for (const branchB of branches) { for (const branchB of branches) {
if(branchA !== branchB) { if(branchA !== branchB) {
const infos = { const isSuperset: boolean = commitHistories[branchA].isSupersetOf(commitHistories[branchB]);
superset: commitHistories[branchA].isSupersetOf(commitHistories[branchB]), const difference: Set<string> = commitHistories[branchA].difference(commitHistories[branchB]);
difference: commitHistories[branchA].difference(commitHistories[branchB])
} if (isSuperset) {
if (infos.superset) {
if(branchB === mainBranch) { if(branchB === mainBranch) {
// SUPERSET OF MAIN BRANCH, MEANING ALREADY REBASED // SUPERSET OF MAIN BRANCH, MEANING ALREADY REBASED
finalBranches[branchA] = { finalBranches[branchA] = {
ignore: true ignore: true
} }
} }
if (infos.difference.size === 0) { if (difference.size === 0) {
const prevBranches: string[] = finalBranches[branchA]?.equalBranches ?? []; const prevBranches: string[] = finalBranches[branchA]?.equalBranches ?? [];
finalBranches[branchA] = { finalBranches[branchA] = {
rebaseBranch: mainBranch, rebaseBranch: mainBranch,
@@ -109,11 +107,11 @@ const buildRebaseDependencyGraph = async (branches: string[]): Promise<Record<st
equalBranches: [...prevBranches, branchB] equalBranches: [...prevBranches, branchB]
}; };
} else { } else {
if (branchA !== mainBranch && (!finalBranches[branchA] || finalBranches[branchA].differenceWithRebase > infos.difference.size)) { if (branchA !== mainBranch && (!finalBranches[branchA] || finalBranches[branchA].differenceWithRebase > difference.size)) {
finalBranches[branchA] = { finalBranches[branchA] = {
...finalBranches[branchA], ...finalBranches[branchA],
rebaseBranch: branchB, rebaseBranch: branchB,
differenceWithRebase: infos.difference.size differenceWithRebase: difference.size
}; };
} }
} }
@@ -175,7 +173,7 @@ const rebaseBranch = async ({
onBranch, onBranch,
action action
}: RebaseAction) => { }: RebaseAction) => {
console.log(`${ action === Action.Rebase ? "Rebasing" : "Resetting" } ${ branch } on ${ onBranch }`); writeConsole(`${ action === Action.Rebase ? "Rebasing" : "Resetting" } ${ branch } on ${ onBranch }`);
await runGitCommand([ await runGitCommand([
"checkout", "checkout",
@@ -255,7 +253,7 @@ const main = async (): Promise<void> => {
} }
} catch (error) { } catch (error) {
writeConsole("Error during workflow execution", LogLevel.ERROR); writeConsole("Error during workflow execution", LogLevel.ERROR);
writeConsole(error.message, LogLevel.ERROR); writeConsole(error, LogLevel.ERROR);
process.exit(1); process.exit(1);
} }
} }

10
dist/app.js vendored

File diff suppressed because one or more lines are too long