diff options
author | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-09-29 17:09:37 -0400 |
---|---|---|
committer | Konstantin Ryabitsev <konstantin@linuxfoundation.org> | 2021-09-29 17:09:37 -0400 |
commit | 9a81f80ee58f61d133391264a303f7f815404d4c (patch) | |
tree | cc3c7eb021f7a21e1a9aa776456357810e6c66ee | |
parent | bd64dab483f6302bbdd792c5e678c0ab51060cbe (diff) | |
download | b4-9a81f80ee58f61d133391264a303f7f815404d4c.tar.gz |
shazam: implement better merging strings
b4 shazam will now:
1. give you a better default message for merging FETCH_HEAD
2. reuse the conver letter for the merge message, giving you the example
invocation for using it
Signed-off-by: Konstantin Ryabitsev <konstantin@linuxfoundation.org>
-rw-r--r-- | b4/mbox.py | 32 |
1 files changed, 32 insertions, 0 deletions
@@ -297,7 +297,39 @@ def make_am(msgs, cmdargs, msgid): logger.critical('Unable to fetch from the worktree') logger.critical(out.strip()) sys.exit(ecode) + # Edit the FETCH_HEAD to give a better default merge message + fhf = os.path.join(topdir, '.git', 'FETCH_HEAD') + with open(fhf, 'r') as fhh: + contents = fhh.read() + linkurl = config['linkmask'] % top_msgid + if len(am_msgs) > 1: + mmsg = 'patches from %s' % linkurl + else: + mmsg = 'patch from %s' % linkurl + new_contents = contents.replace(gwt, mmsg) + if new_contents != contents: + with open(fhf, 'w') as fhh: + fhh.write(contents) + if lser.has_cover: + # Write out a sample merge message using the cover letter + mmf = os.path.join(topdir, '.git', 'b4-cover') + cmsg = lser.patches[0] + parts = b4.LoreMessage.get_body_parts(cmsg.body) + with open(mmf, 'w') as mmh: + mmh.write('Merge %s\n\n' % mmsg) + if len(am_msgs) > 1: + mmh.write('Accept %d patches from %s <%s>\n\n' % (len(am_msgs), cmsg.fromname, cmsg.fromemail)) + else: + mmh.write('Accept patch from %s <%s>\n\n' % (cmsg.fromname, cmsg.fromemail)) + mmh.write('%s\n' % cmsg.subject) + mmh.write('=' * len(cmsg.subject) + '\n') + mmh.write(parts[1]) + mmh.write('=' * len(cmsg.subject) + '\n') + mmh.write('Link: %s\n' % linkurl) + logger.info('You can now merge or checkout FETCH_HEAD') + if lser.has_cover: + logger.info(' e.g.: git merge -F .git/b4-cover --edit FETCH_HEAD') thanks_record_am(lser, cherrypick=cherrypick) return |