aboutsummaryrefslogtreecommitdiff
path: root/b4/__init__.py
diff options
context:
space:
mode:
authorKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-09-30 10:35:10 -0400
committerKonstantin Ryabitsev <konstantin@linuxfoundation.org>2021-09-30 10:35:10 -0400
commit0f46d4c8bf35c7762e96271e7061d42e8dae79e4 (patch)
tree67525e61f5a0f42e37ebf34a9f082d40c75da2d7 /b4/__init__.py
parent9a81f80ee58f61d133391264a303f7f815404d4c (diff)
downloadb4-0f46d4c8bf35c7762e96271e7061d42e8dae79e4.tar.gz
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 <konstantin@linuxfoundation.org>
Diffstat (limited to 'b4/__init__.py')
-rw-r--r--b4/__init__.py17
1 files changed, 16 insertions, 1 deletions
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