Trebejo.Git.Local.Config (Trebejo v2.0.0)

Copy Markdown View Source

Git configuration operations — reading and writing config values, user info, system info and hostname.

Summary

Functions

Gets a Git configuration value (local → global → system).

Gets a Git configuration value from the global scope.

Gets a Git configuration value from the local (repo) scope.

Returns the configured Git user email, or nil if not set.

Returns the configured Git user name, or nil if not set.

Returns the machine's hostname.

Returns the current system user email from the USER_EMAIL env variable, falling back to "user@domain.com".

Returns the current system user name.

Returns a map with the current Git user information.

Sets Git user name, email, and URL rewrite rules globally.

Functions

config(attr, opts \\ [])

@spec config(
  binary(),
  keyword()
) :: binary()

Gets a Git configuration value (local → global → system).

Accepts an optional cd: option to scope the lookup to a specific repository directory.

config_global(attr, opts \\ [])

@spec config_global(
  binary(),
  keyword()
) :: binary()

Gets a Git configuration value from the global scope.

Accepts an optional cd: option (kept for signature parity with config/2; ignored at the global scope).

config_local(attr, opts \\ [])

@spec config_local(
  binary(),
  keyword()
) :: binary()

Gets a Git configuration value from the local (repo) scope.

Accepts an optional cd: option to scope the lookup to a specific repository directory.

get_git_user_email()

@spec get_git_user_email() :: binary() | nil

Returns the configured Git user email, or nil if not set.

get_git_user_name()

@spec get_git_user_name() :: binary() | nil

Returns the configured Git user name, or nil if not set.

get_hostname()

@spec get_hostname() :: binary()

Returns the machine's hostname.

get_system_user_email()

@spec get_system_user_email() :: binary()

Returns the current system user email from the USER_EMAIL env variable, falling back to "user@domain.com".

get_system_user_name()

@spec get_system_user_name() :: binary()

Returns the current system user name.

get_user_info()

@spec get_user_info() :: map()

Returns a map with the current Git user information.

Falls back to system user information if Git is not configured.

set_user_info(name, email)

@spec set_user_info(binary(), binary()) :: :ok | {:error, binary()}

Sets Git user name, email, and URL rewrite rules globally.