Fixed logs
This commit is contained in:
26
app.ts
26
app.ts
@@ -1,7 +1,7 @@
|
||||
import {spawn} from "child_process";
|
||||
import {ChildProcess, SpawnOptions} from "node:child_process";
|
||||
import { spawn } from "child_process";
|
||||
import { ChildProcess, SpawnOptions } from "node:child_process";
|
||||
import * as core from '@actions/core';
|
||||
import {LogLevel, writeConsole} from "@skydust/toolkit";
|
||||
import { LogLevel, writeConsole } from "@skydust/toolkit";
|
||||
|
||||
// Ignored branches
|
||||
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.
|
||||
*/
|
||||
@@ -90,18 +89,17 @@ const buildRebaseDependencyGraph = async (branches: string[]): Promise<Record<st
|
||||
for (const branchA of branches) {
|
||||
for (const branchB of branches) {
|
||||
if(branchA !== branchB) {
|
||||
const infos = {
|
||||
superset: commitHistories[branchA].isSupersetOf(commitHistories[branchB]),
|
||||
difference: commitHistories[branchA].difference(commitHistories[branchB])
|
||||
}
|
||||
if (infos.superset) {
|
||||
const isSuperset: boolean = commitHistories[branchA].isSupersetOf(commitHistories[branchB]);
|
||||
const difference: Set<string> = commitHistories[branchA].difference(commitHistories[branchB]);
|
||||
|
||||
if (isSuperset) {
|
||||
if(branchB === mainBranch) {
|
||||
// SUPERSET OF MAIN BRANCH, MEANING ALREADY REBASED
|
||||
finalBranches[branchA] = {
|
||||
ignore: true
|
||||
}
|
||||
}
|
||||
if (infos.difference.size === 0) {
|
||||
if (difference.size === 0) {
|
||||
const prevBranches: string[] = finalBranches[branchA]?.equalBranches ?? [];
|
||||
finalBranches[branchA] = {
|
||||
rebaseBranch: mainBranch,
|
||||
@@ -109,11 +107,11 @@ const buildRebaseDependencyGraph = async (branches: string[]): Promise<Record<st
|
||||
equalBranches: [...prevBranches, branchB]
|
||||
};
|
||||
} 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],
|
||||
rebaseBranch: branchB,
|
||||
differenceWithRebase: infos.difference.size
|
||||
differenceWithRebase: difference.size
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -175,7 +173,7 @@ const rebaseBranch = async ({
|
||||
onBranch,
|
||||
action
|
||||
}: RebaseAction) => {
|
||||
console.log(`${ action === Action.Rebase ? "Rebasing" : "Resetting" } ${ branch } on ${ onBranch }`);
|
||||
writeConsole(`${ action === Action.Rebase ? "Rebasing" : "Resetting" } ${ branch } on ${ onBranch }`);
|
||||
|
||||
await runGitCommand([
|
||||
"checkout",
|
||||
@@ -255,7 +253,7 @@ const main = async (): Promise<void> => {
|
||||
}
|
||||
} catch (error) {
|
||||
writeConsole("Error during workflow execution", LogLevel.ERROR);
|
||||
writeConsole(error.message, LogLevel.ERROR);
|
||||
writeConsole(error, LogLevel.ERROR);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user