Compare commits

...

1 Commits

Author SHA1 Message Date
Ashcon Partovi
9cb4e07915 ci: Fix changed files detection for forks 2024-11-12 14:20:53 -08:00
2 changed files with 16 additions and 1 deletions

View File

@@ -14,6 +14,7 @@ import {
getCommitMessage,
getLastSuccessfulBuild,
getMainBranch,
getRepositoryOwner,
getTargetBranch,
isBuildkite,
isFork,
@@ -370,7 +371,7 @@ async function main() {
}
console.log("Checking changed files...");
const baseRef = getCommit();
const baseRef = isFork() ? `${getRepositoryOwner()}:${getCommit()}` : getCommit();
console.log(" - Base Ref:", baseRef);
const headRef = lastBuild?.commit_id || getTargetBranch() || getMainBranch();
console.log(" - Head Ref:", headRef);

View File

@@ -376,6 +376,20 @@ export function getRepository(cwd) {
}
}
/**
* @param {string} [cwd]
* @returns {string | undefined}
*/
export function getRepositoryOwner(cwd) {
const repository = getRepository(cwd);
if (repository) {
const [owner] = repository.split("/");
if (owner) {
return owner;
}
}
}
/**
* @param {string} [cwd]
* @returns {string | undefined}