or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

Files

docs

command.mdconfiguration.mddatabase.mddiff.mdexceptions.mdindex-staging.mdindex.mdobjects.mdreferences.mdremote.mdrepository.md

configuration.mddocs/

0

# Configuration

1

2

Access to Git configuration at repository, user, and system levels. Supports reading and writing configuration values with proper scope management and type conversion.

3

4

## Capabilities

5

6

```python { .api }

7

class GitConfigParser:

8

def __init__(self, file_or_files: Union[str, list, None] = None, read_only: bool = True, merge_includes: bool = True, config_level: str = None):

9

"""Initialize config parser."""

10

11

def get_value(self, section: str, option: str, default: Any = None) -> Any:

12

"""Get configuration value."""

13

14

def set_value(self, section: str, option: str, value: Any) -> "GitConfigParser":

15

"""Set configuration value."""

16

17

def write(self) -> None:

18

"""Write configuration to file."""

19

20

def read(self) -> None:

21

"""Read configuration from file."""

22

23

def has_option(self, section: str, option: str) -> bool:

24

"""Check if option exists."""

25

26

def remove_option(self, section: str, option: str) -> bool:

27

"""Remove configuration option."""

28

29

def remove_section(self, section: str) -> bool:

30

"""Remove configuration section."""

31

32

class SectionConstraint:

33

"""Configuration section constraints."""

34

```

35

36

## Usage Examples

37

38

```python

39

from git import Repo

40

41

repo = Repo('/path/to/repo')

42

43

# Read configuration

44

config = repo.config_reader()

45

user_name = config.get_value('user', 'name')

46

user_email = config.get_value('user', 'email')

47

48

# Write configuration

49

with repo.config_writer() as config:

50

config.set_value('user', 'name', 'John Doe')

51

config.set_value('user', 'email', 'john@example.com')

52

config.set_value('core', 'editor', 'vim')

53

54

# Access different config levels

55

user_config = repo.config_reader('user')

56

system_config = repo.config_reader('system')

57

```