Remove duplication on the repo / pr messages

This commit is contained in:
Graham Christensen 2017-11-24 13:36:46 -05:00
parent b5f70a53c0
commit 80f720fe02
No known key found for this signature in database
GPG key ID: ACA1C1D120C83D5C

View file

@ -82,23 +82,27 @@ impl worker::SimpleWorker for GitHubCommentWorker {
let pr = pr.unwrap(); let pr = pr.unwrap();
let repo_msg = Repo {
clone_url: job.repository.clone_url.clone(),
full_name: job.repository.full_name.clone(),
owner: job.repository.owner.login.clone(),
name: job.repository.name.clone(),
};
let pr_msg = Pr {
number: job.issue.number.clone(),
head_sha: pr.head.sha.clone(),
target_branch: Some(pr.base.commit_ref.clone())
};
let mut response: Vec<worker::Action> = vec![]; let mut response: Vec<worker::Action> = vec![];
if let Some(instructions) = instructions { if let Some(instructions) = instructions {
for instruction in instructions { for instruction in instructions {
match instruction { match instruction {
commentparser::Instruction::Build(attrs) => { commentparser::Instruction::Build(attrs) => {
let msg = buildjob::BuildJob{ let msg = buildjob::BuildJob{
repo: Repo { repo: repo_msg.clone(),
clone_url: job.repository.clone_url.clone(), pr: pr_msg.clone(),
full_name: job.repository.full_name.clone(),
owner: job.repository.owner.login.clone(),
name: job.repository.name.clone(),
},
pr: Pr {
number: job.issue.number.clone(),
head_sha: pr.head.sha.clone(),
target_branch: Some(pr.base.commit_ref.clone())
},
subset: Some(buildjob::Subset::Nixpkgs), subset: Some(buildjob::Subset::Nixpkgs),
attrs: attrs, attrs: attrs,
}; };
@ -121,17 +125,8 @@ impl worker::SimpleWorker for GitHubCommentWorker {
} }
commentparser::Instruction::Eval => { commentparser::Instruction::Eval => {
let msg = massrebuildjob::MassRebuildJob{ let msg = massrebuildjob::MassRebuildJob{
repo: Repo { repo: repo_msg.clone(),
clone_url: job.repository.clone_url.clone(), pr: pr_msg.clone(),
full_name: job.repository.full_name.clone(),
owner: job.repository.owner.login.clone(),
name: job.repository.name.clone(),
},
pr: Pr {
number: job.issue.number.clone(),
head_sha: pr.head.sha.clone(),
target_branch: Some(pr.base.commit_ref.clone()),
},
}; };
let props = BasicProperties { let props = BasicProperties {