git

Git configuration utilities.

struct GitAuthor

source

pub struct GitAuthor

Author identity resolved from git config.

Field Type Description
email Option<String> Email address from user.email, or None when unset.
name String Display name from user.name or the $USER fallback.

fn resolve_author

source

pub fn resolve_author() -> Option<GitAuthor>

Resolve the current git user identity from git config.

Reads user.name and user.email from git config. Returns None if user.name is not configured. email is optional and may be None even when name is present.

Parameter Type Description
returns Option<GitAuthor> The author; None also when git cannot run.

fn resolve_author_or_env

source

pub fn resolve_author_or_env() -> Option<GitAuthor>

Resolve the current user identity, trying git config first, then $USER.

Parameter Type Description
returns Option<GitAuthor> The author from git config, else one named by $USER with no email. Returns None only if both git config and $USER are unavailable.

fn git_config

source

fn git_config(key: &str) -> Option<String>

Read one value with git config <key>.

Parameter Type Description
key &str the config key, such as user.name
returns Option<String> The trimmed value, or None when the key is unset, empty, or git cannot run.