Xgit v0.8.0 Xgit.ConfigFile View Source

This GenServer monitors and potentially updates the contents of an on-disk git config file.

See https://git-scm.com/docs/git-config for details on the config file format.

Link to this section Summary

Types

Error codes that can be returned by remove_entries/2.

t()

Process ID for an Xgit.ConfigFile process.

Functions

Returns a specification to start this module under a supervisor.

Return any configuration entries that match the requested search.

Removes all configuration entries that match the requested search.

Start a ConfigFile for a config file at the given path.

Create or update a config value.

Link to this section Types

Link to this type

remove_entries_reason()

View Source
remove_entries_reason() :: File.posix()

Error codes that can be returned by remove_entries/2.

Process ID for an Xgit.ConfigFile process.

Link to this section Functions

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

get_entries(config_file, opts \\ [])

View Source
get_entries(config_file :: t(),
  section: String.t(),
  subsection: String.t(),
  name: String.t()
) :: [Xgit.ConfigEntry.t()]

Return any configuration entries that match the requested search.

Entries will be returned in the order in which they appeared in the underlying file.

Options

  • section: (String) if provided, only returns entries in the named section
  • subsection: (String) if provided, only returns entries in the named subsection (only meaningful if section is also provided)
  • name: (String) if provided, only returns entries with the given variable name (only meaningful if section is also provided)

If section is provided but subsection is not, then only items within the top-level section (i.e. with no subsection) will be matched.

If no options are provided, returns all entries.

A list of Xgit.ConfigEntry structs that match the search parameters.

Link to this function

remove_entries(config_file, opts \\ [])

View Source
remove_entries(config_file :: t(),
  section: String.t(),
  subsection: String.t(),
  name: String.t()
) :: :ok | {:error, reason :: remove_entries_reason()}

Removes all configuration entries that match the requested search.

Options

  • section: (String) if provided, only removes entries in the named section
  • subsection: (String) if provided, only removes entries in the named subsection (only meaningful if section is also provided)
  • name: (String) if provided, only removes entries with the given variable name (only meaningful if section is also provided)

If section is provided but subsection is not, then only items within the top-level section (i.e. with no subsection) will be removed.

If no options are provided, removes all entries.

Returns :ok regardless of whether any matching entries were found and removed.

Link to this function

start_link(path)

View Source
start_link(path :: Path.t()) :: GenServer.on_start()

Start a ConfigFile for a config file at the given path.

The path (including parent directory) needs to exist, but there need not be a file at this path.

Link to this function

update(config_file, value, opts)

View Source
update(config_file :: t(), value :: nil | String.t(),
  section: String.t(),
  subsection: String.t(),
  name: String.t(),
  add?: boolean(),
  replace_all?: boolean()
) :: :ok | {:error, :replacing_multivar}

Create or update a config value.

Parameters

value (nil or String) value to be added to this variable

Options

  • section: required section to add the value to
  • subsection: (optional) subsection to add the value to
  • name: required name of variable to update or replace
  • add?: if true, adds this value to any that may already exist
  • replace_all?: if true, removes all existing entries that match any keys provided

Return Values

:ok if successful.

{:error, :replacing_multivar} if the existing variable has multiple variables. Replacing such a variable requires either add?: true or replace_all?: true.