-
-
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 (#302)
* 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. * Rebasing with master, and renaming User to Author * Fixing tests. Ok, this time I run the tests before commmiting :')
- Loading branch information
Showing
26 changed files
with
82 additions
and
82 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 |
---|---|---|
|
@@ -210,7 +210,7 @@ impl<'octo> RepoHandler<'octo> { | |
/// Creates a new file in the repository. | ||
/// ```no_run | ||
/// # async fn run() -> octocrab::Result<()> { | ||
/// use octocrab::models::repos::GitUser; | ||
/// use octocrab::models::repos::CommitAuthor; | ||
/// | ||
/// // Commit to add "crabs/ferris.txt" | ||
/// octocrab::instance() | ||
|
@@ -221,11 +221,11 @@ impl<'octo> RepoHandler<'octo> { | |
/// "Thought there’d never be a Rust Rap?\n" | ||
/// ) | ||
/// .branch("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(), | ||
/// }) | ||
|
@@ -253,7 +253,7 @@ impl<'octo> RepoHandler<'octo> { | |
/// ```no_run | ||
/// # async fn run() -> octocrab::Result<()> { | ||
/// # let blob_sha = ""; | ||
/// use octocrab::models::repos::GitUser; | ||
/// use octocrab::models::repos::CommitAuthor; | ||
/// | ||
/// // Given the file blob for "crabs/ferris.txt", commit to update the file. | ||
/// octocrab::instance() | ||
|
@@ -265,11 +265,11 @@ impl<'octo> RepoHandler<'octo> { | |
/// blob_sha | ||
/// ) | ||
/// .branch("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(), | ||
/// }) | ||
|
@@ -299,7 +299,7 @@ impl<'octo> RepoHandler<'octo> { | |
/// ```no_run | ||
/// # async fn run() -> octocrab::Result<()> { | ||
/// # let blob_sha = ""; | ||
/// use octocrab::models::repos::GitUser; | ||
/// use octocrab::models::repos::CommitAuthor; | ||
/// | ||
/// // Commit to delete "crabs/ferris.txt" | ||
/// octocrab::instance() | ||
|
@@ -310,11 +310,11 @@ impl<'octo> RepoHandler<'octo> { | |
/// blob_sha | ||
/// ) | ||
/// .branch("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
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
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
Oops, something went wrong.