From 0f46d4c8bf35c7762e96271e7061d42e8dae79e4 Mon Sep 17 00:00:00 2001 From: Konstantin Ryabitsev Date: Thu, 30 Sep 2021 10:35:10 -0400 Subject: shazam: implement custom merge message templates Allow people to set up their own preferred merge templates, using the netdev standard as default. Signed-off-by: Konstantin Ryabitsev --- b4/__init__.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'b4/__init__.py') diff --git a/b4/__init__.py b/b4/__init__.py index 47272bb..b352d6a 100644 --- a/b4/__init__.py +++ b/b4/__init__.py @@ -1895,7 +1895,7 @@ def git_temp_worktree(gitdir=None, commitish=None): yield dfn finally: if dfn is not None: - git_run_command(gitdir, ['worktree', 'remove', dfn]) + git_run_command(gitdir, ['worktree', 'remove', '--force', dfn]) @contextmanager @@ -2461,3 +2461,18 @@ def get_mailinfo(bmsg: bytes, scissors: bool = False) -> Tuple[dict, bytes, byte with open(p_out, 'rb') as pfh: p = pfh.read() return i, m, p + + +def read_template(tptfile): + # bubbles up FileNotFound + tpt = '' + if tptfile.find('~') >= 0: + tptfile = os.path.expanduser(tptfile) + if tptfile.find('$') >= 0: + tptfile = os.path.expandvars(tptfile) + with open(tptfile, 'r', encoding='utf-8') as fh: + for line in fh: + if len(line) and line[0] == '#': + continue + tpt += line + return tpt -- cgit v1.2.3