aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTeddy Wing2017-11-09 01:14:38 +0100
committerTeddy Wing2017-11-09 01:14:38 +0100
commit254fa3fb4411f96ecd02f0c69a89ba5f2a5c8c95 (patch)
tree9ef4ceb7f61536170f98e634430ec3b501745d18 /src
parentdf0b5cd4b3c4af93019e2f628fa32101242d4ec2 (diff)
downloadkipper-254fa3fb4411f96ecd02f0c69a89ba5f2a5c8c95.tar.bz2
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.
Diffstat (limited to 'src')
-rw-r--r--src/af83.rs1
-rw-r--r--src/github.rs1
-rw-r--r--src/jenkins.rs2
-rw-r--r--src/pull_request.rs3
4 files changed, 7 insertions, 0 deletions
diff --git a/src/af83.rs b/src/af83.rs
index b3b8bf7..bc8876c 100644
--- a/src/af83.rs
+++ b/src/af83.rs
@@ -14,6 +14,7 @@ mod tests {
#[test]
fn job_name_is_branch_appended_by_commit_sha_prefix() {
let commit_ref = CommitRef {
+ owner: "sybil".to_string(),
repo: "sybil-system".to_string(),
sha: "159f8769b897ed7774700d0b2777def8ac838b8f".to_string(),
branch: "5912-make-logo-bigger".to_string(),
diff --git a/src/github.rs b/src/github.rs
index d246c4e..325f6bf 100644
--- a/src/github.rs
+++ b/src/github.rs
@@ -84,6 +84,7 @@ mod tests {
.create();
let commit_ref = CommitRef {
+ owner: "octocat".to_string(),
repo: "Hello-World".to_string(),
sha: "6dcb09b5b57875f334f61aebed695e2e4193db5e".to_string(),
branch: "not-used".to_string(),
diff --git a/src/jenkins.rs b/src/jenkins.rs
index 9868b50..37e5879 100644
--- a/src/jenkins.rs
+++ b/src/jenkins.rs
@@ -261,6 +261,7 @@ mod tests {
};
let commit_ref = CommitRef {
+ owner: "uso".to_string(),
repo: "vivid-system".to_string(),
sha: "b4a286e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c".to_string(),
branch: "1753-fix-everything".to_string(),
@@ -277,6 +278,7 @@ mod tests {
};
let commit_ref = CommitRef {
+ owner: "uso".to_string(),
repo: "vivid-system".to_string(),
sha: "b4a286e67d8f5eaf1f6ba5c57fc3c7d91ac0fd1c".to_string(),
branch: "1753-fix-everything".to_string(),
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");