@@ -2,7 +2,11 @@ import type { H3Event } from "h3";
22import type { components as OctokitComponents } from "@octokit/openapi-types" ;
33import type { Comment , PackageManager } from "@pkg-pr-new/utils" ;
44import type { WorkflowData } from "../types" ;
5- import { isPullRequest , isWhitelisted } from "@pkg-pr-new/utils" ;
5+ import {
6+ isPullRequest ,
7+ isValidGitHash ,
8+ isWhitelisted ,
9+ } from "@pkg-pr-new/utils" ;
610import { randomUUID } from "uncrypto" ;
711import { setItemStream , useTemplatesBucket } from "../utils/bucket" ;
812import { useOctokitInstallation } from "../utils/octokit" ;
@@ -23,6 +27,7 @@ export default eventHandler(async (event) => {
2327 "sb-only-templates" : onlyTemplatesHeader ,
2428 "sb-comment-with-sha" : commentWithShaHeader ,
2529 "sb-comment-with-dev" : commentWithDevHeader ,
30+ "sb-sha" : shaOverride ,
2631 } = getHeaders ( event ) ;
2732 const compact = compactHeader === "true" ;
2833 const onlyTemplates = onlyTemplatesHeader === "true" ;
@@ -54,6 +59,16 @@ export default eventHandler(async (event) => {
5459 } ) ;
5560 }
5661
62+ if ( shaOverride ) {
63+ if ( ! isValidGitHash ( shaOverride ) ) {
64+ throw createError ( {
65+ statusCode : 400 ,
66+ message : "Invalid sb-sha: must be a 40-character hex SHA" ,
67+ } ) ;
68+ }
69+ workflowData . sha = shaOverride ;
70+ }
71+
5772 const whitelisted = await isWhitelisted (
5873 workflowData . owner ,
5974 workflowData . repo ,
0 commit comments