Skip to content

Commit

Permalink
Merge pull request #7 from trunk-io/eli/more-detail
Browse files Browse the repository at this point in the history
MergeQueue Tool Updates for content
  • Loading branch information
EliSchleifer authored Apr 15, 2024
2 parents cd12d19 + 3d16689 commit 13d9561
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 9 deletions.
4 changes: 4 additions & 0 deletions .trunk/trunk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ actions:
- trunk-fmt-pre-commit
- trunk-upgrade-available

lint:
enabled:
- [email protected]

tools:
enabled:
- [email protected]
2 changes: 1 addition & 1 deletion src/github.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub struct Event {
pub struct PullRequest {
pub number: u32,
pub head: Head,
pub body: String,
pub body: Option<String>,
}

#[derive(Serialize, Deserialize, Debug)]
Expand Down
14 changes: 9 additions & 5 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,22 @@ fn create_pull_request(
}

let mut body = config.pullrequest.body.to_string();
body.push_str("\n\n[test]");
body.push_str(&format!("\nflake rate: {}", config.test.flake_rate));
body.push_str("\n\n[test]\n");
body.push_str(&format!("flake rate: {}\n", config.test.flake_rate));
body.push_str(&format!(
"\nlogical conflict every: {}",
"logical conflict every: {}\n",
config.pullrequest.logical_conflict_every
));
body.push_str(&format!(
"\nsleep for: {}s",
"sleep for: {}s\n",
config.sleep_duration().as_secs()
));
body.push_str(&format!(
"\n\n[pullrequest]\nrequests per hour: {}",
"close stale after: {}\n",
config.pullrequest.close_stale_after
));
body.push_str(&format!(
"\n\n[pullrequest]\nrequests per hour: {}\n",
config.pullrequest.requests_per_hour
));

Expand Down
11 changes: 8 additions & 3 deletions src/trunk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> = 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())
Expand Down

0 comments on commit 13d9561

Please sign in to comment.