mirror of
https://github.com/peakoss/anti-slop
synced 2026-11-28 13:37:41 +08:00
fix(check): skip merge checks when user profile is private
This commit is contained in:
3 files changed
+13
-4
No files matched your search
@@ -6,9 +6,15 @@ export async function runMergeChecks(
|
||||
settings: Settings,
|
||||
context: Context,
|
||||
client: Octokit,
|
||||
isPrivateProfile: boolean,
|
||||
): Promise<CheckResult[]> {
|
||||
const results: CheckResult[] = [];
|
||||
|
||||
if (isPrivateProfile) {
|
||||
core.info("[SKIP] merge-checks - Merge checks cannot be computed for private profiles");
|
||||
return results;
|
||||
}
|
||||
|
||||
const user = context.userLogin;
|
||||
const repoFull = `${context.owner}/${context.repo}`;
|
||||
const globalScope = settings.globalMergeRatioExcludeOwn ? `-user:${user}` : "";
|
||||
|
||||
@@ -11,7 +11,7 @@ export async function runUserChecks(
|
||||
settings: Settings,
|
||||
context: Context,
|
||||
client: Octokit,
|
||||
): Promise<CheckResult[]> {
|
||||
): Promise<{ results: CheckResult[]; isPrivateProfile: boolean }> {
|
||||
const results: CheckResult[] = [];
|
||||
|
||||
const user = context.userLogin;
|
||||
@@ -104,7 +104,7 @@ export async function runUserChecks(
|
||||
});
|
||||
}
|
||||
|
||||
return results;
|
||||
return { results, isPrivateProfile: profile?.user_view_type !== "public" };
|
||||
}
|
||||
|
||||
async function getUserProfile(client: Octokit, username: string): Promise<UserProfile> {
|
||||
|
||||
+5
-2
@@ -76,11 +76,14 @@ export async function run(): Promise<void> {
|
||||
core.endGroup();
|
||||
|
||||
core.startGroup("User checks");
|
||||
results.push(...(await runUserChecks(settings, context, client)));
|
||||
const userChecks = await runUserChecks(settings, context, client);
|
||||
results.push(...userChecks.results);
|
||||
core.endGroup();
|
||||
|
||||
core.startGroup("Merge checks");
|
||||
results.push(...(await runMergeChecks(settings, context, client)));
|
||||
results.push(
|
||||
...(await runMergeChecks(settings, context, client, userChecks.isPrivateProfile)),
|
||||
);
|
||||
core.endGroup();
|
||||
} else {
|
||||
core.warning("No valid GitHub token — checks requiring the GitHub API were skipped");
|
||||
|
||||
Reference in new issue
Block a user