-
-
Notifications
You must be signed in to change notification settings - Fork 272
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix the model for parsing responses to a specific commit sha.
The response from Github to something like: https://api.github.com/repos/[owner]/[repo]/commits/[sha], has two type of Authors. Prior to these changes the "author" key in the root level has different fields than the "author" key from the praent "commit" key. This commit fixes the problem by properly naming the fields so the parser don't mix the two "author" keys.
- Loading branch information
Showing
24 changed files
with
73 additions
and
73 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
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
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 |
---|---|---|
|
@@ -58,9 +58,9 @@ pub struct UpdateFileBuilder<'octo, 'r> { | |
#[serde(skip_serializing_if = "Option::is_none")] | ||
branch: Option<String>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
commiter: Option<models::repos::GitUser>, | ||
commiter: Option<models::repos::CommitAuthor>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
author: Option<models::repos::GitUser>, | ||
author: Option<models::repos::CommitAuthor>, | ||
} | ||
|
||
impl<'octo, 'r> UpdateFileBuilder<'octo, 'r> { | ||
|
@@ -90,13 +90,13 @@ impl<'octo, 'r> UpdateFileBuilder<'octo, 'r> { | |
} | ||
|
||
/// The person that commited the file. | ||
pub fn commiter(mut self, commiter: impl Into<models::repos::GitUser>) -> Self { | ||
pub fn commiter(mut self, commiter: impl Into<models::repos::CommitAuthor>) -> Self { | ||
self.commiter = Some(commiter.into()); | ||
self | ||
} | ||
|
||
/// The author of the file. | ||
pub fn author(mut self, author: impl Into<models::repos::GitUser>) -> Self { | ||
pub fn author(mut self, author: impl Into<models::repos::CommitAuthor>) -> Self { | ||
self.author = Some(author.into()); | ||
self | ||
} | ||
|
@@ -124,9 +124,9 @@ pub struct DeleteFileBuilder<'octo, 'r> { | |
#[serde(skip_serializing_if = "Option::is_none")] | ||
branch: Option<String>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
commiter: Option<models::repos::GitUser>, | ||
commiter: Option<models::repos::CommitAuthor>, | ||
#[serde(skip_serializing_if = "Option::is_none")] | ||
author: Option<models::repos::GitUser>, | ||
author: Option<models::repos::CommitAuthor>, | ||
} | ||
|
||
impl<'octo, 'r> DeleteFileBuilder<'octo, 'r> { | ||
|
@@ -154,13 +154,13 @@ impl<'octo, 'r> DeleteFileBuilder<'octo, 'r> { | |
} | ||
|
||
/// The person that commited the file. | ||
pub fn commiter(mut self, commiter: impl Into<models::repos::GitUser>) -> Self { | ||
pub fn commiter(mut self, commiter: impl Into<models::repos::CommitAuthor>) -> Self { | ||
self.commiter = Some(commiter.into()); | ||
self | ||
} | ||
|
||
/// The author of the file. | ||
pub fn author(mut self, author: impl Into<models::repos::GitUser>) -> Self { | ||
pub fn author(mut self, author: impl Into<models::repos::CommitAuthor>) -> Self { | ||
self.author = Some(author.into()); | ||
self | ||
} | ||
|
@@ -179,7 +179,7 @@ impl<'octo, 'r> DeleteFileBuilder<'octo, 'r> { | |
|
||
#[cfg(test)] | ||
mod tests { | ||
use crate::models::repos::GitUser; | ||
use crate::models::repos::CommitAuthor; | ||
|
||
#[test] | ||
fn serialize() { | ||
|
@@ -193,11 +193,11 @@ mod tests { | |
"testsha", | ||
) | ||
.branch("not-master") | ||
.commiter(GitUser { | ||
.commiter(CommitAuthor { | ||
name: "Octocat".to_string(), | ||
email: "[email protected]".to_string(), | ||
}) | ||
.author(GitUser { | ||
.author(CommitAuthor { | ||
name: "Ferris".to_string(), | ||
email: "[email protected]".to_string(), | ||
}); | ||
|
@@ -228,11 +228,11 @@ mod tests { | |
let builder = repo | ||
.delete_file("tests/test.txt", "Update test.txt", "testsha") | ||
.branch("not-master") | ||
.commiter(GitUser { | ||
.commiter(CommitAuthor { | ||
name: "Octocat".to_string(), | ||
email: "[email protected]".to_string(), | ||
}) | ||
.author(GitUser { | ||
.author(CommitAuthor { | ||
name: "Ferris".to_string(), | ||
email: "[email protected]".to_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
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
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
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
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 |
---|---|---|
|
@@ -20,7 +20,7 @@ pub struct PushEventPayload { | |
mod test { | ||
use crate::models::{ | ||
events::{payload::EventPayload, Event}, | ||
repos::GitUser, | ||
repos::CommitAuthor, | ||
}; | ||
use reqwest::Url; | ||
|
||
|
@@ -43,7 +43,7 @@ mod test { | |
assert_eq!(commit.sha, "eb1a60c03544dcea290f2d57bb66ae188ce25778"); | ||
assert_eq!( | ||
commit.author, | ||
GitUser { | ||
CommitAuthor { | ||
name: "readme-bot".to_string(), | ||
email: "[email protected]".to_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
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
Oops, something went wrong.