-
-
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
81 additions
and
38 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,50 @@ | ||
use crate::commitstatus; | ||
use crate::message; | ||
|
||
use hubcaps::checks::{CheckRun, CheckRunOptions}; | ||
use hubcaps::issues::IssueRef; | ||
use hubcaps::repositories::Repository; | ||
use hubcaps::statuses::{Status, StatusOptions}; | ||
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_status(&self, sha: &str, status: &StatusOptions) -> hubcaps::Result<Status> { | ||
self.repo.statuses().create(sha, status) | ||
} | ||
|
||
pub fn create_checkrun(&self, check: &CheckRunOptions) -> hubcaps::Result<CheckRun> { | ||
self.repo.checkruns().create(&check) | ||
} | ||
|
||
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, | ||
) | ||
} | ||
} |
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