Merge lp:~jelmer/brz/git-config-section-options into lp:brz

Proposed by Jelmer Vernooij
Status: Merged
Approved by: Jelmer Vernooij
Approved revision: 7628
Merge reported by: The Breezy Bot
Merged at revision: not available
Proposed branch: lp:~jelmer/brz/git-config-section-options
Merge into: lp:brz
Diff against target: 57 lines (+21/-4)
1 file modified
breezy/git/config.py (+21/-4)
To merge this branch: bzr merge lp:~jelmer/brz/git-config-section-options
Reviewer Review Type Date Requested Status
Jelmer Vernooij Approve
Review via email: mp+429396@code.launchpad.net

Commit message

Support accessing git branch configuration.

Description of the change

Support accessing git branch configuration.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'breezy/git/config.py'
2--- breezy/git/config.py 2020-03-22 01:35:14 +0000
3+++ breezy/git/config.py 2022-09-04 22:46:48 +0000
4@@ -47,7 +47,9 @@
5 class GitConfigSectionDefault(config.Section):
6 """The "default" config section in git config file"""
7
8- def __init__(self, config):
9+ id = None
10+
11+ def __init__(self, id, config):
12 self._config = config
13
14 def get(self, name, default=None, expand=True):
15@@ -69,16 +71,31 @@
16 return key.decode()
17 return None
18
19+ def iter_option_names(self):
20+ try:
21+ self._config.get((b'user', ), b'email')
22+ except KeyError:
23+ pass
24+ else:
25+ yield 'email'
26+ try:
27+ self._config.get((b'user', ), b'signingkey')
28+ except KeyError:
29+ pass
30+ else:
31+ yield 'gpg_signing_key'
32+
33
34 class GitConfigStore(config.Store):
35 """Store that uses gitconfig."""
36
37- def __init__(self, config):
38+ def __init__(self, id, config):
39+ self.id = id
40 self._config = config
41
42 def get_sections(self):
43 return [
44- (self, GitConfigSectionDefault(self._config)),
45+ (self, GitConfigSectionDefault('default', self._config)),
46 ]
47
48
49@@ -94,7 +111,7 @@
50 # local git branches.
51 git = getattr(branch.repository, '_git', None)
52 if git:
53- cstore = GitConfigStore(git.get_config())
54+ cstore = GitConfigStore('branch', git.get_config())
55 section_getters.append(cstore.get_sections)
56 gstore = config.GlobalStore()
57 section_getters.append(gstore.get_sections)

Subscribers

People subscribed via source and target branches