From 254fa3fb4411f96ecd02f0c69a89ba5f2a5c8c95 Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Thu, 9 Nov 2017 01:14:38 +0100 Subject: CommitRef: Add `owner` field This field stores the "owner" of the commit on GitHub, in other words, a user or organisation. Storing that information in this struct makes it easier to pass around. --- src/pull_request.rs | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/pull_request.rs') diff --git a/src/pull_request.rs b/src/pull_request.rs index 0766085..f775a5a 100644 --- a/src/pull_request.rs +++ b/src/pull_request.rs @@ -3,6 +3,7 @@ extern crate json; #[derive(Debug)] pub struct CommitRef { + pub owner: String, pub repo: String, pub sha: String, pub branch: String, @@ -18,6 +19,7 @@ impl CommitRef { .collect(); CommitRef { + owner: github_push_event["repository"]["owner"]["name"].take_string().unwrap(), repo: github_push_event["repository"]["name"].take_string().unwrap(), sha: github_push_event["head_commit"]["id"].take_string().unwrap(), branch: branch_parts.last().unwrap().to_string(), @@ -198,6 +200,7 @@ mod tests { let commit_ref = CommitRef::new(payload); + assert_eq!(commit_ref.owner, "baxterthehacker"); assert_eq!(commit_ref.repo, "public-repo"); assert_eq!(commit_ref.sha, "0d1a26e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c"); assert_eq!(commit_ref.branch, "changes"); -- cgit v1.2.3