Skip to content

Commit

Permalink
chore: empty string test
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4007 committed Oct 8, 2024
1 parent 26e265b commit 2c8fc07
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions .github/empty-string-checker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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);

Expand Down

0 comments on commit 2c8fc07

Please sign in to comment.