Skip to content

Commit 4c37daf

Browse files
Apply suggestion from @szokeasaurusrex
Co-authored-by: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com>
1 parent 10df508 commit 4c37daf

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

src/utils/vcs.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,15 +590,17 @@ pub fn find_head() -> Result<String> {
590590
/// Extracts the PR head SHA from GitHub Actions event payload JSON.
591591
/// Returns None if not a PR event or if SHA cannot be extracted.
592592
fn extract_pr_head_sha_from_event(json_content: &str) -> Option<String> {
593-
let payload: GitHubEventPayload = match serde_json::from_str(json_content) {
594-
Ok(payload) => payload,
593+
let v: Value = match serde_json::from_str(json_content) {
594+
Ok(v) => v,
595595
Err(_) => {
596596
debug!("Failed to parse GitHub event payload as JSON");
597597
return None;
598598
}
599599
};
600600

601-
Some(payload.pull_request?.head.sha)
601+
v.pointer("/pull_request/head/sha")
602+
.and_then(|s| s.as_str())
603+
.map(|s| s.to_owned())
602604
}
603605

604606
/// Given commit specs, repos and remote_name this returns a list of head

0 commit comments

Comments
 (0)