-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #339 from apollographql/avery/s-comitter-author
fix: s/committer/author
- Loading branch information
Showing
3 changed files
with
20 additions
and
20 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 \<[email protected]\>"). More info [here](#git-context) | | ||
| `APOLLO_VCS_AUTHOR` | The name and email of a commit's author (ex. "Jane Doe \<[email protected]\>"). 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. |
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 |
---|---|---|
|
@@ -10,7 +10,7 @@ use git_url_parse::GitUrl; | |
#[derive(Debug, PartialEq)] | ||
pub struct GitContext { | ||
pub branch: Option<String>, | ||
pub committer: Option<String>, | ||
pub author: Option<String>, | ||
pub commit: Option<String>, | ||
pub message: Option<String>, | ||
pub remote_url: Option<String>, | ||
|
@@ -25,15 +25,15 @@ 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, | ||
}) | ||
} | ||
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<Option<String>> { | ||
Ok(env.get(RoverEnvKey::VcsCommitter)?.or_else(|| { | ||
let mut committer = None; | ||
fn get_author(env: &RoverEnv, head: Option<&Reference>) -> Result<Option<String>> { | ||
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<GraphPublishContextInput> 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<GraphCheckContextInput> 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<SubgraphPublishContextInput> 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<SubgraphCheckContextInput> 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 = "[email protected]: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); | ||
|