-
-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
eval: partially split up github interactions
- Loading branch information
Showing
3 changed files
with
76 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::commitstatus; | ||
use crate::message; | ||
|
||
use hubcaps::checks::CheckRunOptions; | ||
use hubcaps::issues::IssueRef; | ||
use hubcaps::repositories::Repository; | ||
use hubcaps::Github; | ||
|
||
pub struct Client<'a> { | ||
repo: Repository<'a>, | ||
} | ||
|
||
impl<'a> Client<'a> { | ||
pub fn new(github: &'a Github, repo: &message::Repo) -> Self { | ||
let repo = github.repo(repo.owner.clone(), repo.name.clone()); | ||
Client { repo } | ||
} | ||
|
||
pub fn get_repo(&self) -> &Repository<'a> { | ||
&self.repo | ||
} | ||
|
||
pub fn get_issue_ref(&self, number: u64) -> IssueRef { | ||
self.repo.issue(number) | ||
} | ||
|
||
pub fn create_commitstatus( | ||
&self, | ||
pr: &message::Pr, | ||
context: String, | ||
description: String, | ||
) -> commitstatus::CommitStatus { | ||
commitstatus::CommitStatus::new( | ||
self.repo.statuses(), | ||
pr.head_sha.clone(), | ||
context, | ||
description, | ||
None, | ||
) | ||
} | ||
|
||
pub fn create_checkrun(&self, check: &CheckRunOptions) -> Result<(), hubcaps::Error> { | ||
self.repo.checkruns().create(&check)?; | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters