From fc109bb4046d04fa4f0603cbbf92cf2f1abe805b Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Mon, 29 Dec 2025 01:58:59 +0000 Subject: [PATCH] refactor: clean check_skip_if_match.cjs - Replace || with ?? (nullish coalescing) for better empty string handling - Remove unnecessary explanatory comments - Remove redundant return statement in catch block - Reduce code from 64 to 57 lines (11% reduction) This file already has comprehensive test coverage with 14 test cases. --- actions/setup/js/check_skip_if_match.cjs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/actions/setup/js/check_skip_if_match.cjs b/actions/setup/js/check_skip_if_match.cjs index f54b56875ca..95093621a62 100644 --- a/actions/setup/js/check_skip_if_match.cjs +++ b/actions/setup/js/check_skip_if_match.cjs @@ -6,7 +6,7 @@ const { getErrorMessage } = require("./error_helpers.cjs"); async function main() { const skipQuery = process.env.GH_AW_SKIP_QUERY; const workflowName = process.env.GH_AW_WORKFLOW_NAME; - const maxMatchesStr = process.env.GH_AW_SKIP_MAX_MATCHES || "1"; + const maxMatchesStr = process.env.GH_AW_SKIP_MAX_MATCHES ?? "1"; if (!skipQuery) { core.setFailed("Configuration error: GH_AW_SKIP_QUERY not specified."); @@ -27,20 +27,15 @@ async function main() { core.info(`Checking skip-if-match query: ${skipQuery}`); core.info(`Maximum matches threshold: ${maxMatches}`); - // Get repository information from context const { owner, repo } = context.repo; - - // Scope the query to the current repository const scopedQuery = `${skipQuery} repo:${owner}/${repo}`; core.info(`Scoped query: ${scopedQuery}`); try { - // Search for issues and pull requests using the GitHub API - // We only need to know if the count reaches the threshold const response = await github.rest.search.issuesAndPullRequests({ q: scopedQuery, - per_page: 1, // We only need the count, not the items + per_page: 1, }); const totalCount = response.data.total_count; @@ -56,7 +51,6 @@ async function main() { core.setOutput("skip_check_ok", "true"); } catch (error) { core.setFailed(`Failed to execute search query: ${getErrorMessage(error)}`); - return; } }