Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig-checker
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"Version": "v3.0.1",
"Version": "v3.0.3",
"Verbose": false,
"Format": "",
"Debug": false,
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/git-town.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,5 @@ jobs:
- uses: actions/checkout@v4
- name: Git Town
uses: ./
with:
skip-single-stacks: true
3 changes: 3 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ inputs:
perennial-regex:
required: false
default: ''
skip-single-stacks:
required: false
default: false

runs:
using: 'node20'
Expand Down
48 changes: 34 additions & 14 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18741,7 +18741,7 @@ var require_core = __commonJS({
return inputs2.map((input) => input.trim());
}
exports2.getMultilineInput = getMultilineInput2;
function getBooleanInput(name, options) {
function getBooleanInput2(name, options) {
const trueValue = ["true", "True", "TRUE"];
const falseValue = ["false", "False", "FALSE"];
const val = getInput2(name, options);
Expand All @@ -18752,7 +18752,7 @@ var require_core = __commonJS({
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}
Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports2.getBooleanInput = getBooleanInput;
exports2.getBooleanInput = getBooleanInput2;
function setOutput(name, value) {
const filePath = process.env["GITHUB_OUTPUT"] || "";
if (filePath) {
Expand Down Expand Up @@ -42837,7 +42837,8 @@ async function main({
mainBranch,
perennialBranches,
currentPullRequest,
pullRequests
pullRequests,
skipSingleStacks
}) {
const repoGraph = new import_graphology.MultiDirectedGraph();
repoGraph.addNode(mainBranch, {
Expand All @@ -42860,28 +42861,28 @@ async function main({
repoGraph.addDirectedEdge(pullRequest.baseRefName, pullRequest.headRefName);
});
const getStackGraph = (pullRequest) => {
const stackGraph = repoGraph.copy();
stackGraph.setNodeAttribute(pullRequest.headRefName, "isCurrent", true);
const stackGraph2 = repoGraph.copy();
stackGraph2.setNodeAttribute(pullRequest.headRefName, "isCurrent", true);
(0, import_graphology_traversal.bfsFromNode)(
stackGraph,
stackGraph2,
pullRequest.headRefName,
(ref, attributes) => {
stackGraph.setNodeAttribute(ref, "shouldPrint", true);
stackGraph2.setNodeAttribute(ref, "shouldPrint", true);
return attributes.type === "perennial";
},
{
mode: "inbound"
}
);
(0, import_graphology_traversal.dfsFromNode)(
stackGraph,
stackGraph2,
pullRequest.headRefName,
(ref) => {
stackGraph.setNodeAttribute(ref, "shouldPrint", true);
stackGraph2.setNodeAttribute(ref, "shouldPrint", true);
},
{ mode: "outbound" }
);
return stackGraph;
return stackGraph2;
};
const getOutput = (graph) => {
const lines = [];
Expand Down Expand Up @@ -42910,14 +42911,25 @@ async function main({
return lines.join("\n");
};
const jobs = [];
getStackGraph(currentPullRequest).forEachNode((_, stackNode) => {
const stackGraph = getStackGraph(currentPullRequest);
const shouldSkip = () => {
const neighbors = stackGraph.neighbors(currentPullRequest.headRefName);
const allPerennialBranches = stackGraph.filterNodes(
(_, nodeAttributes) => nodeAttributes.type === "perennial"
);
return skipSingleStacks && neighbors.length === 1 && allPerennialBranches.includes(neighbors.at(0) || "");
};
if (shouldSkip()) {
return;
}
stackGraph.forEachNode((_, stackNode) => {
if (stackNode.type !== "pull-request" || !stackNode.shouldPrint) {
return;
}
jobs.push(async () => {
core.info(`Updating stack details for PR #${stackNode.number}`);
const stackGraph = getStackGraph(stackNode);
const output = getOutput(stackGraph);
const stackGraph2 = getStackGraph(stackNode);
const output = getOutput(stackGraph2);
let description = stackNode.body ?? "";
description = updateDescription({
description,
Expand Down Expand Up @@ -46824,6 +46836,13 @@ var inputs = {
getToken() {
return core2.getInput("github-token", { required: true, trimWhitespace: true });
},
getSkipSingleStacks() {
core2.startGroup("Inputs: Skip single stacks");
const input = core2.getBooleanInput("skip-single-stacks", { required: false });
core2.info(input.toString());
core2.endGroup();
return input;
},
async getMainBranch(octokit, config2, context3) {
const {
data: { default_branch: defaultBranch }
Expand Down Expand Up @@ -46975,7 +46994,8 @@ async function run() {
currentPullRequest: inputs.getCurrentPullRequest(github2.context),
pullRequests,
mainBranch,
perennialBranches
perennialBranches,
skipSingleStacks: inputs.getSkipSingleStacks()
};
void main(context3);
} catch (error) {
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ async function run() {
pullRequests,
mainBranch,
perennialBranches,
skipSingleStacks: inputs.getSkipSingleStacks(),
}

void main(context)
Expand Down
8 changes: 8 additions & 0 deletions src/inputs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,14 @@ export const inputs = {
return core.getInput('github-token', { required: true, trimWhitespace: true })
},

getSkipSingleStacks() {
core.startGroup('Inputs: Skip single stacks')
const input = core.getBooleanInput('skip-single-stacks', { required: false })
core.info(input.toString())
core.endGroup()
return input
},

async getMainBranch(
octokit: Octokit,
config: Config | undefined,
Expand Down
22 changes: 21 additions & 1 deletion src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export async function main({
perennialBranches,
currentPullRequest,
pullRequests,
skipSingleStacks,
}: Context) {
const repoGraph = new MultiDirectedGraph<StackNodeAttributes>()

Expand Down Expand Up @@ -101,7 +102,26 @@ export async function main({

const jobs: Array<() => Promise<void>> = []

getStackGraph(currentPullRequest).forEachNode((_, stackNode) => {
const stackGraph = getStackGraph(currentPullRequest)

const shouldSkip = () => {
const neighbors = stackGraph.neighbors(currentPullRequest.headRefName)
const allPerennialBranches = stackGraph.filterNodes(
(_, nodeAttributes) => nodeAttributes.type === 'perennial'
)

return (
skipSingleStacks &&
neighbors.length === 1 &&
allPerennialBranches.includes(neighbors.at(0) || '')
)
}

if (shouldSkip()) {
return
}

stackGraph.forEachNode((_, stackNode) => {
if (stackNode.type !== 'pull-request' || !stackNode.shouldPrint) {
return
}
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export type Context = {
currentPullRequest: PullRequest
pullRequests: PullRequest[]
perennialBranches: string[]
skipSingleStacks: boolean
}

export type StackNode =
Expand Down
Empty file added stack1
Empty file.