Adding table for failed rebase
This commit is contained in:
34
app.ts
34
app.ts
@@ -1,7 +1,7 @@
|
||||
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, styledTable, writeConsole } from "@skydust/toolkit";
|
||||
|
||||
// Ignored branches
|
||||
const IGNORED_BRANCHES: string[] = core.getInput('branchesToIgnore', { required: false }).split(",");
|
||||
@@ -172,13 +172,16 @@ const rebaseOrder = (branchesWithDependencies: Record<string, BranchWithDependen
|
||||
|
||||
}
|
||||
|
||||
const rebaseBranch = async ({
|
||||
branch,
|
||||
onBranch,
|
||||
action
|
||||
}: RebaseAction) => {
|
||||
const rebaseBranch = async (rebaseAction: RebaseAction): Promise<RebaseAction & { success: boolean }> => {
|
||||
let {
|
||||
branch,
|
||||
onBranch,
|
||||
action
|
||||
} = rebaseAction;
|
||||
|
||||
writeConsole(`${ action === Action.Rebase ? "Rebasing" : "Resetting" } ${ branch } on ${ onBranch }`);
|
||||
|
||||
let doneWithSuccess = true;
|
||||
await runGitCommand([
|
||||
"checkout",
|
||||
branch.replace("origin/", "")
|
||||
@@ -195,6 +198,7 @@ const rebaseBranch = async ({
|
||||
"rebase",
|
||||
"--abort"
|
||||
])
|
||||
doneWithSuccess = false;
|
||||
});
|
||||
} else if(action === Action.Reset) {
|
||||
await runGitCommand([
|
||||
@@ -208,6 +212,8 @@ const rebaseBranch = async ({
|
||||
"push",
|
||||
"--force-with-lease"
|
||||
]);
|
||||
|
||||
return { ...rebaseAction, success: doneWithSuccess };
|
||||
}
|
||||
|
||||
const setupCIToken = async () => {
|
||||
@@ -285,8 +291,22 @@ const main = async (): Promise<void> => {
|
||||
}
|
||||
|
||||
// Step 4: Rebase branches
|
||||
const rebasedBranches: (RebaseAction & { success: boolean })[] = [];
|
||||
for (const rebaseAction of order) {
|
||||
await rebaseBranch(rebaseAction);
|
||||
rebasedBranches.push(await rebaseBranch(rebaseAction));
|
||||
}
|
||||
|
||||
const failedRebase = rebasedBranches.filter(rebased => !rebased.success)
|
||||
.map(rebased => [rebased.branch, rebased.onBranch, rebased.action] as string[]);
|
||||
|
||||
if(failedRebase.length === 0) {
|
||||
writeConsole("All rebase where done successfully", LogLevel.INFO);
|
||||
} else {
|
||||
writeConsole("Some rebase failed", LogLevel.WARNING);
|
||||
styledTable([
|
||||
["Branch", "Action", "Onto branch"],
|
||||
...failedRebase
|
||||
]);
|
||||
}
|
||||
} catch (error) {
|
||||
writeConsole("Error during workflow execution", LogLevel.ERROR);
|
||||
|
||||
Reference in New Issue
Block a user