-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move collect_approved_reviews to a member function of Changeset
- Loading branch information
1 parent
5e9d9f7
commit 2acf77b
Showing
3 changed files
with
30 additions
and
32 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 |
---|---|---|
@@ -1,21 +1,39 @@ | ||
use octocrab::models::pulls::Review; | ||
use octocrab::models::pulls::ReviewState::Approved; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct RepoChangeset { | ||
pub name: String, | ||
pub remote: String, | ||
pub name: String, | ||
pub remote: String, | ||
pub base_commit: String, | ||
pub head_commit: String, | ||
pub changes: Vec<Changeset>, | ||
pub changes: Vec<Changeset>, | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct Changeset { | ||
pub commits: Vec<CommitMetadata>, | ||
pub pr_link: Option<String>, | ||
pub commits: Vec<CommitMetadata>, | ||
pub pr_link: Option<String>, | ||
pub approvals: Vec<String>, | ||
} | ||
|
||
impl Changeset { | ||
pub fn collect_approved_reviews(&mut self, pr_reviews: &[Review]) { | ||
for pr_review in pr_reviews { | ||
// TODO: do we need to check if this is the last review of the user? | ||
if pr_review.state == Some(Approved) { | ||
let Some(ref user) = pr_review.user else { | ||
continue; | ||
}; | ||
|
||
self.approvals.push(user.login.clone()); | ||
} | ||
} | ||
} | ||
} | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct CommitMetadata { | ||
pub headline: String, | ||
pub link: String, | ||
pub link: String, | ||
} |
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