Used inputs

This commit is contained in:
2024-12-27 14:55:25 +01:00
parent 758107ea92
commit 0a5f230d30
3 changed files with 19832 additions and 10 deletions

View File

@@ -5,10 +5,13 @@ author: Skydust
# Define your inputs here.
inputs:
branchesToIgnore:
description: The username
required: true
branchesToRebaseOn:
description: ""
description: Comma separated branches to ignore
default: "dev,main,master"
required: false
mainBranch:
description: "The main branch to rebase on"
default: "dev"
required: false
runs:
using: 'node20'

14
app.ts
View File

@@ -1,10 +1,11 @@
import { spawn } from "child_process";
import { ChildProcess, SpawnOptions } from "node:child_process";
import * as core from '@actions/core';
// Ignored branches
const IGNORED_BRANCHES = ["master", "main", "dev", "release"];
const IGNORED_BRANCHES: string[] = core.getInput('branchesToIgnore', { required: false }).split(",");
const mainBranch = "dev";
const mainBranch: string = core.getInput('mainBranch', { required: false });
enum Action {
Rebase = 0,
@@ -27,8 +28,9 @@ interface BranchWithDependencies {
/**
* Helper function to run a Git command and capture stdout and stderr.
*/
const runGitCommand = (args: string[], options?: SpawnOptions): Promise<string> =>
new Promise((resolve, reject) => {
const runGitCommand = (args: string[], options?: SpawnOptions): Promise<string> => {
console.log(`Running git command: git ${ args.join(" ") }`);
return new Promise((resolve, reject) => {
const git: ChildProcess = spawn("git", args, { stdio: "pipe", ...options });
let stdout: string = "";
let stderr: string = "";
@@ -41,6 +43,8 @@ const runGitCommand = (args: string[], options?: SpawnOptions): Promise<string>
resolve(stdout) :
reject(new Error(`Git command failed with code ${code}: ${stderr}`)));
});
}
/**
* Fetch all remote branches.
@@ -78,6 +82,7 @@ const buildRebaseDependencyGraph = async (branches: string[]): Promise<Record<st
const commitHistories: Record<string, Set<string>> = {};
for (const branch of branches) {
commitHistories[branch] = await getCommitsForBranch(branch);
console.log(commitHistories[branch]);
}
let finalBranches: Record<string, BranchWithDependencies> = {};
@@ -115,6 +120,7 @@ const buildRebaseDependencyGraph = async (branches: string[]): Promise<Record<st
}
}
}
console.log(finalBranches);
// Set rebase for branches with no dependencies
for (const branch of branches) {

19817
dist/app.js vendored

File diff suppressed because one or more lines are too long