From 3d16689566587b3dc64bd3372e07ad59d001bcbf Mon Sep 17 00:00:00 2001 From: Jane Doe Date: Mon, 15 Apr 2024 18:01:17 +0000 Subject: [PATCH] --- src/github.rs | 2 +- src/trunk.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/github.rs b/src/github.rs index 527675e..2095ab0 100644 --- a/src/github.rs +++ b/src/github.rs @@ -31,7 +31,7 @@ pub struct Event { pub struct PullRequest { pub number: u32, pub head: Head, - pub body: String, + pub body: Option, } #[derive(Serialize, Deserialize, Debug)] diff --git a/src/trunk.rs b/src/trunk.rs index 85a84ab..4e3869a 100644 --- a/src/trunk.rs +++ b/src/trunk.rs @@ -8,12 +8,17 @@ use std::fs; pub fn upload_targets(config: &Conf, cli: &Cli, github_json_path: &str) { let github_json = fs::read_to_string(github_json_path).expect("Failed to read file"); - let ga = GitHubAction::from_json(&github_json); - let re = Regex::new(r".*deps=\[(.*?)\].*").unwrap(); + if !&ga.event.pull_request.body.is_some() { + // no body content to pull deps from + return; + } + + let re = Regex::new(r".*deps=\[(.*?)\].*").unwrap(); + let body = ga.event.pull_request.body.clone().unwrap(); let mut impacted_targets: Vec = Vec::new(); - if let Some(caps) = re.captures(&ga.event.pull_request.body) { + if let Some(caps) = re.captures(&body) { impacted_targets = caps[1] .split(',') .map(|s| s.trim().to_owned())