aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-09-13 16:41:02 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2022-09-13 16:41:02 -0400
commit02757cc36088b96bfe1a7ea37b9512060ffcc4b9 (patch)
treeb5203ff64bb35fa0eb53c0c5902b3cecf7f3613d
parent9d7be6fb9103cf7dd5418e79782a187b9c2d7cf0 (diff)
downloadb4-02757cc36088b96bfe1a7ea37b9512060ffcc4b9.tar.gz
Improve worktree-default configuration loading
If we find a ~/.b4-config, we load it up before parsing any other configuration values we find. This allows us to override any worktree defaults by user-specific settings. Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r--.b4-config2
-rw-r--r--b4/__init__.py33
2 files changed, 22 insertions, 13 deletions
diff --git a/.b4-config b/.b4-config
index 3f20a71..df74d79 100644
--- a/.b4-config
+++ b/.b4-config
@@ -1,4 +1,6 @@
[b4]
+ midmask = https://lore.kernel.org/%s
+ linkmask = https://msgid.link/%s
send-series-to = Kernel.org Tools <tools@linux.kernel.org>
send-series-cc = Konstantin Ryabitsev <konstantin@linuxfoundation.org>
send-endpoint-web = https://lkml.kernel.org/_b4_submit
diff --git a/b4/__init__.py b/b4/__init__.py
index 8a358f0..c773326 100644
--- a/b4/__init__.py
+++ b/b4/__init__.py
@@ -2246,26 +2246,33 @@ def get_config_from_git(regexp: str, defaults: Optional[dict] = None,
def get_main_config() -> dict:
global MAIN_CONFIG
if MAIN_CONFIG is None:
- config = get_config_from_git(r'b4\..*', defaults=DEFAULT_CONFIG, multivals=['keyringsrc'])
- config['listid-preference'] = config['listid-preference'].split(',')
- config['listid-preference'].remove('*')
- config['listid-preference'].append('*')
- if config['gpgbin'] is None:
- gpgcfg = get_config_from_git(r'gpg\..*', {'program': 'gpg'})
- config['gpgbin'] = gpgcfg['program']
-
- # send- options can be provided via the toplevel .b4-config file
+ defcfg = copy.deepcopy(DEFAULT_CONFIG)
+ # some options can be provided via the toplevel .b4-config file,
+ # so load them up and use as defaults
topdir = git_get_toplevel()
+ wtglobs = ['send-*', '*mask', '*template*']
if topdir:
wtcfg = os.path.join(topdir, '.b4-config')
if os.access(wtcfg, os.R_OK):
logger.debug('Loading worktree configs from %s', wtcfg)
- wtconfig = get_config_from_git(r'b4\.send-.*', source=wtcfg)
+ wtconfig = get_config_from_git(r'b4\..*', source=wtcfg)
logger.debug('wtcfg=%s', wtconfig)
- # We don't override any other settings
for key, val in wtconfig.items():
- if key not in config:
- config[key] = val
+ if val.startswith('./'):
+ # replace it with full topdir path
+ val = os.path.abspath(os.path.join(topdir, val))
+ for wtglob in wtglobs:
+ if fnmatch.fnmatch(key, wtglob):
+ logger.debug('wtcfg: %s=%s', key, val)
+ defcfg[key] = val
+ break
+ config = get_config_from_git(r'b4\..*', defaults=defcfg, multivals=['keyringsrc'])
+ config['listid-preference'] = config['listid-preference'].split(',')
+ config['listid-preference'].remove('*')
+ config['listid-preference'].append('*')
+ if config['gpgbin'] is None:
+ gpgcfg = get_config_from_git(r'gpg\..*', {'program': 'gpg'})
+ config['gpgbin'] = gpgcfg['program']
MAIN_CONFIG = config