Skip to content

Commit 9a4694a

Browse files
beamerblvdjdavid
authored andcommitted
Refactor Config to extract DefaultConfig and RepositoryConfig subclasses
This refactors `Config` to extract two new subclasses, `DefaultConfig` and `RepositoryConfig`, which are used to logically and semantically indicate the purpose of a given `Config` object. This also substantially improves the documentation for the existing `Config` class.
1 parent c8fcaf6 commit 9a4694a

7 files changed

Lines changed: 681 additions & 125 deletions

File tree

‎docs/config.rst‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,31 @@
22
Configuration files
33
**********************************************************************
44

5-
.. autoclass:: pygit2.Repository
6-
:members: config
7-
:noindex:
5+
.. autoclass:: pygit2.repository.BaseRepository
6+
:members: config, config_snapshot
87

98

10-
The Config type
9+
The Config types
1110
================
1211

1312
.. autoclass:: pygit2.Config
1413
:members:
1514
:undoc-members:
16-
:special-members: __contains__, __delitem__, __getitem__, __iter__, __setitem__
15+
:special-members: __contains__, __delitem__, __getitem__, __init__, __iter__, __setitem__
16+
17+
.. autoclass:: pygit2.DefaultConfig
18+
:members: add_file, snapshot
19+
:undoc-members:
20+
:special-members: __init__
21+
22+
.. autoclass:: pygit2.RepositoryConfig
23+
:members: add_file, snapshot
24+
:undoc-members:
25+
:special-members: __init__
1726

1827

1928
The ConfigEntry type
2029
====================
2130

2231
.. autoclass:: pygit2.config.ConfigEntry
23-
:members: name, value, level
32+
:members: level, name, raw_level, raw_name, raw_value, value, __eq__, __hash__

‎pygit2/__init__.py‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,11 @@
301301
git_fetch_options,
302302
git_proxy_options,
303303
)
304-
from .config import Config
304+
from .config import (
305+
Config,
306+
DefaultConfig,
307+
RepositoryConfig,
308+
)
305309
from .credentials import *
306310
from .errors import (
307311
AlreadyExistsError,
@@ -606,6 +610,7 @@ def filter_unregister(name: str) -> None:
606610
'Branch',
607611
'CertificateError',
608612
'Commit',
613+
'DefaultConfig',
609614
'Diff',
610615
'DiffDelta',
611616
'DiffFile',
@@ -941,6 +946,7 @@ def filter_unregister(name: str) -> None:
941946
'Remote',
942947
'repository',
943948
'Repository',
949+
'RepositoryConfig',
944950
'branches',
945951
'references',
946952
'settings',

0 commit comments

Comments
 (0)