From 2c8fc075d14d390456e71ad86beed41d42264342 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=82=A2=E3=83=AC=E3=82=AF=E3=82=B5=E3=83=B3=E3=83=80?= =?UTF-8?q?=E3=83=BC=2Eeth?= Date: Wed, 9 Oct 2024 06:56:26 +0900 Subject: [PATCH] chore: empty string test --- .github/empty-string-checker.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/empty-string-checker.ts b/.github/empty-string-checker.ts index a903f3e..1c109a0 100644 --- a/.github/empty-string-checker.ts +++ b/.github/empty-string-checker.ts @@ -4,8 +4,9 @@ import simpleGit from "simple-git"; const token = process.env.GITHUB_TOKEN; const [owner, repo] = process.env.GITHUB_REPOSITORY?.split("/") || []; const pullNumber = process.env.GITHUB_PR_NUMBER || process.env.PULL_REQUEST_NUMBER || "0"; +const baseRef = process.env.GITHUB_BASE_REF; -if (!token || !owner || !repo || pullNumber === "0") { +if (!token || !owner || !repo || pullNumber === "0" || !baseRef) { console.error("Missing required environment variables."); process.exit(1); } @@ -25,8 +26,11 @@ async function run() { const baseSha = pullRequest.base.sha; const headSha = pullRequest.head.sha; + // Fetch the base branch + await git.fetch(["origin", baseRef]); + // Get the diff of the pull request using the SHAs - const diff = await git.diff([`${baseSha}...${headSha}`]); + const diff = await git.diff([`origin/${baseRef}...${headSha}`]); const violations = parseDiffForEmptyStrings(diff);