diff --git a/docs/source/configuring.md b/docs/source/configuring.md index 2370e5258..699275c9d 100644 --- a/docs/source/configuring.md +++ b/docs/source/configuring.md @@ -99,7 +99,7 @@ If present, an environment variable's value takes precedence over all other meth | `APOLLO_VCS_REMOTE_URL` | The location of your project's repository. More info [here](#git-context) | | `APOLLO_VCS_BRANCH` | The name of the version controlled branch. More info [here](#git-context) | | `APOLLO_VCS_COMMIT` | The long identifier (sha in git) of the commit. More info [here](#git-context) | -| `APOLLO_VCS_COMMITTER` | The name and email of the contributor (ex. "Jane Doe \"). More info [here](#git-context) | +| `APOLLO_VCS_AUTHOR` | The name and email of a commit's author (ex. "Jane Doe \"). More info [here](#git-context) | ## Advanced @@ -114,6 +114,6 @@ This information powers the ability to be able to link to a specific commit from To see these values, just run any `check` or `publish` command with the `--log trace` option. -None of this information should be sensitive, but if you would rather overwrite these values, you may use the `APOLLO_VCS_REMOTE_URL`, `APOLLO_VCS_BRANCH`, `APOLLO_VCS_COMMIT`, and `APOLLO_VCS_COMMITTER` environment variables documented [here](./configuring#all-supported-environment-variables). +None of this information should be sensitive, but if you would rather overwrite these values, you may use the `APOLLO_VCS_REMOTE_URL`, `APOLLO_VCS_BRANCH`, `APOLLO_VCS_COMMIT`, and `APOLLO_VCS_AUTHOR` environment variables documented [here](./configuring#all-supported-environment-variables). **Non-git users** may also use these vaiables to set similar information relevant to your VCS tool, but only git is fully supported by Apollo Studio. diff --git a/src/utils/env.rs b/src/utils/env.rs index 0145d79a8..b5e2d0159 100644 --- a/src/utils/env.rs +++ b/src/utils/env.rs @@ -114,7 +114,7 @@ pub enum RoverEnvKey { VcsRemoteUrl, VcsBranch, VcsCommit, - VcsCommitter, + VcsAuthor, } impl fmt::Display for RoverEnvKey { diff --git a/src/utils/git.rs b/src/utils/git.rs index 78de9017a..4d51bed20 100644 --- a/src/utils/git.rs +++ b/src/utils/git.rs @@ -10,7 +10,7 @@ use git_url_parse::GitUrl; #[derive(Debug, PartialEq)] pub struct GitContext { pub branch: Option, - pub committer: Option, + pub author: Option, pub commit: Option, pub message: Option, pub remote_url: Option, @@ -25,7 +25,7 @@ impl GitContext { Ok(Self { branch: GitContext::get_branch(env, head.as_ref())?, commit: GitContext::get_commit(env, head.as_ref())?, - committer: GitContext::get_committer(env, head.as_ref())?, + author: GitContext::get_author(env, head.as_ref())?, remote_url: GitContext::get_remote_url(env, Some(&repo))?, message: None, }) @@ -33,7 +33,7 @@ impl GitContext { Err(_) => Ok(Self { branch: GitContext::get_branch(env, None)?, commit: GitContext::get_commit(env, None)?, - committer: GitContext::get_committer(env, None)?, + author: GitContext::get_author(env, None)?, remote_url: GitContext::get_remote_url(env, None)?, message: None, }), @@ -62,15 +62,15 @@ impl GitContext { })) } - fn get_committer(env: &RoverEnv, head: Option<&Reference>) -> Result> { - Ok(env.get(RoverEnvKey::VcsCommitter)?.or_else(|| { - let mut committer = None; + fn get_author(env: &RoverEnv, head: Option<&Reference>) -> Result> { + Ok(env.get(RoverEnvKey::VcsAuthor)?.or_else(|| { + let mut author = None; if let Some(head) = head { if let Ok(head_commit) = head.peel_to_commit() { - committer = Some(head_commit.committer().to_string()) + author = Some(head_commit.author().to_string()) } } - committer + author })) } @@ -137,7 +137,7 @@ impl Into for GitContext { GraphPublishContextInput { branch: self.branch, commit: self.commit, - committer: self.committer, + committer: self.author, remote_url: self.remote_url, message: self.message, } @@ -150,7 +150,7 @@ impl Into for GitContext { GraphCheckContextInput { branch: self.branch, commit: self.commit, - committer: self.committer, + committer: self.author, remote_url: self.remote_url, message: self.message, } @@ -164,7 +164,7 @@ impl Into for GitContext { SubgraphPublishContextInput { branch: self.branch, commit: self.commit, - committer: self.committer, + committer: self.author, remote_url: self.remote_url, message: self.message, } @@ -177,7 +177,7 @@ impl Into for GitContext { SubgraphCheckContextInput { branch: self.branch, commit: self.commit, - committer: self.committer, + committer: self.author, remote_url: self.remote_url, message: self.message, } @@ -314,19 +314,19 @@ mod tests { #[test] fn it_can_create_git_context_from_env() { let branch = "mybranch".to_string(); - let committer = "test subject number one".to_string(); + let author = "test subject number one".to_string(); let commit = "f84b32caddddfdd9fa87d7ce2140d56eabe805ee".to_string(); let remote_url = "git@bitbucket.org:roku/theworstremoteintheworld.git".to_string(); let mut rover_env = RoverEnv::new(); rover_env.insert(RoverEnvKey::VcsBranch, &branch); - rover_env.insert(RoverEnvKey::VcsCommitter, &committer); + rover_env.insert(RoverEnvKey::VcsAuthor, &author); rover_env.insert(RoverEnvKey::VcsCommit, &commit); rover_env.insert(RoverEnvKey::VcsRemoteUrl, &remote_url); let expected_git_context = GitContext { branch: Some(branch), - committer: Some(committer), + author: Some(author), commit: Some(commit), message: None, remote_url: Some(remote_url), @@ -339,12 +339,12 @@ mod tests { } #[test] - fn it_can_create_git_context_committ_committer_remote_url() { + fn it_can_create_git_context_committ_author_remote_url() { let git_context = GitContext::try_from_rover_env(&RoverEnv::new()).expect("Could not create git context"); assert!(git_context.branch.is_some()); - assert!(git_context.committer.is_some()); + assert!(git_context.author.is_some()); if let Some(commit) = git_context.commit { assert_eq!(commit.len(), 40);