gr::remote

Function read_config

Source
pub fn read_config(
    config_path: ConfigFilePath,
    url: &RemoteURL,
) -> Result<Arc<dyn ConfigProperties>>
Expand description

Reads configuration from TOML file. The config_file is the main default config file and it holds global configuration. Additionally, this function will attempt to gather configurations named after the domain and the project we are targeting. This is so the main config does not become unnecessarily large when providing merge request configuration for a specific project. The total configuration is as if we concatenated them all into one, so headers cannot be named the same across different configuration files. The configuration for a specific domain or project can go to either config file but cannot be mixed. Ex.

  • gitar.toml - left empty
  • github_com.toml - holds configuration for github.com
  • github_com_jordilin_gitar.toml - holds configuration for jordilin/gitar

But also, we could just have:

  • gitar.toml - left empty
  • github_com_jordilin_gitar.toml - holds configuration for gitub.com and jordilin/gitar
  • github_com.toml - left empty

Up to the user how he/she wants to organize the TOML configuration across files as long as TOML headers are unique and abide by the configuration format supported by Gitar.

If all files are missing, then a default configuration is returned. That is gitar works with no configuration as long as auth tokens are provided via environment variables. Ex. CI/CD use cases and one-offs.