-
Notifications
You must be signed in to change notification settings - Fork 94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add git info to check/push #205
Conversation
src/cli.rs
Outdated
|
||
// constructing GitContext with a set of overrides from env vars | ||
let git_context = GitContext::new(branch, committer, commit, remote_url); | ||
tracing::debug!("Git Context: {:?}", git_context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tracing::debug!("Git Context: {:?}", git_context); | |
tracing::debug!("Git Context", ?git_context); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't work for me, I get an error saying
error: expected expression, found `?`
--> src/cli.rs:97:40
|
97 | tracing::debug!("Git Context", ?git_context);
| ^ expected expression
src/git.rs
Outdated
) -> Self { | ||
let git = git_info::get(); | ||
|
||
let branch = if override_branch.is_none() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these could all be one liners
let branch = override_branch.unwrap_or_else(|| git.current_branch);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't quite work, because git.current_branch
is an Option<String>
, so the return types clash of it either being a string
from the unwrapping of override_branch
or an Option<String>
from git.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're looking for or()
! So:
let branch = override_branch.or(git.current_branch);
src/git.rs
Outdated
if user.is_empty() && email.is_empty() { | ||
None | ||
} else { | ||
Some(format!("{} {}", user, email)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this gets a bit murky if user is empty and email is not - wonder if that's a common case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
definitely a common case i've seen a whole bunch
src/git.rs
Outdated
let remote_url = if let Some(remote) = remote_url { | ||
GitContext::sanitize_remote_url(&remote) | ||
} else { | ||
None | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let remote_url = remote_url.map(|url| GitContext::sanitize_remote_url(&url));
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result of this would also be the wrong type, it'd be Option<Option<String>>
instead of Option<String>
- creates GitContext::new() that takes no arguments - creates GitContext::with_env() that uses RoverEnv store to create git object - separates out GitContext::committer() and GitContext::remote() into their own logic methods
Adds the ability to pass git info to all check/push commands for use in Apollo Studio
git
module to the crate