Configuration files
- class pygit2.Repository(path=None, flags=0)
- property config
The configuration file for this repository.
If a the configuration hasn’t been set yet, the default config for repository will be returned, including global and system configurations (if they are available).
The Config type
- class pygit2.Config(path=None)
Git configuration management.
- __contains__(key)
- __delitem__(key)
- __getitem__(key)
When using the mapping interface, the value is returned as a string. In order to apply the git-config parsing rules, you can use
Config.get_bool()
orConfig.get_int()
.
- __iter__()
Iterate over configuration entries, returning a
ConfigEntry
objects. These contain the name, level, and value of each configuration variable. Be aware that this may return multiple versions of each entry if they are set multiple times in the configuration files.
- __setitem__(key, value)
- add_file(path, level=0, force=0)
Add a config file instance to an existing config.
- delete_multivar(name, regex)
Delete a multivar ‘’name’’. ‘’regexp’’ is a regular expression to indicate which values to delete.
- classmethod from_c(repo, ptr)
- get_bool(key)
Look up key and parse its value as a boolean as per the git-config rules. Return a boolean value (True or False).
Truthy values are: ‘true’, 1, ‘on’ or ‘yes’. Falsy values are: ‘false’, 0, ‘off’ and ‘no’
- static get_global_config()
Return a <Config> object representing the global configuration file.
- get_int(key)
Look up key and parse its value as an integer as per the git-config rules. Return an integer.
A value can have a suffix ‘k’, ‘m’ or ‘g’ which stand for ‘kilo’, ‘mega’ and ‘giga’ respectively.
- get_multivar(name, regex=None)
Get each value of a multivar ‘’name’’ as a list of strings.
The optional ‘’regex’’ parameter is expected to be a regular expression to filter the variables we’re interested in.
- static get_system_config()
Return a <Config> object representing the system configuration file.
- static get_xdg_config()
Return a <Config> object representing the global configuration file.
- static parse_bool(text)
- static parse_int(text)
- set_multivar(name, regex, value)
Set a multivar ‘’name’’ to ‘’value’’. ‘’regexp’’ is a regular expression to indicate which values to replace.
- snapshot()
Create a snapshot from this Config object.
This means that looking up multiple values will use the same version of the configuration files.