summaryrefslogtreecommitdiffstats
path: root/tools/patman/patchstream.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-29 21:46:36 -0600
committerSimon Glass <sjg@chromium.org>2020-11-05 09:11:31 -0700
commit8f9ba3ab56c49880fb13fc483493b635f787627c (patch)
treeb83166cab86194a61fa68b982a31e73309e42a8b /tools/patman/patchstream.py
parentdc6df972c9ee2afefd937bee3771865012daccef (diff)
downloadu-boot-8f9ba3ab56c49880fb13fc483493b635f787627c.tar.gz
u-boot-8f9ba3ab56c49880fb13fc483493b635f787627c.tar.xz
u-boot-8f9ba3ab56c49880fb13fc483493b635f787627c.zip
patman: Support updating a branch with review tags
It is tedious to add review tags into the local branch and errors can sometimes be made. Add an option to create a new branch with the review tags obtained from patchwork. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/patman/patchstream.py')
-rw-r--r--tools/patman/patchstream.py52
1 files changed, 49 insertions, 3 deletions
diff --git a/tools/patman/patchstream.py b/tools/patman/patchstream.py
index b3a25d59d1..a4bf08b7d8 100644
--- a/tools/patman/patchstream.py
+++ b/tools/patman/patchstream.py
@@ -551,6 +551,54 @@ class PatchStream:
self.blank_count = 0
self.finalise()
+def insert_tags(msg, tags_to_emit):
+ """Add extra tags to a commit message
+
+ The tags are added after an existing block of tags if found, otherwise at
+ the end.
+
+ Args:
+ msg (str): Commit message
+ tags_to_emit (list): List of tags to emit, each a str
+
+ Returns:
+ (str) new message
+ """
+ out = []
+ done = False
+ emit_tags = False
+ for line in msg.splitlines():
+ if not done:
+ signoff_match = RE_SIGNOFF.match(line)
+ tag_match = RE_TAG.match(line)
+ if tag_match or signoff_match:
+ emit_tags = True
+ if emit_tags and not tag_match and not signoff_match:
+ out += tags_to_emit
+ emit_tags = False
+ done = True
+ out.append(line)
+ if not done:
+ out.append('')
+ out += tags_to_emit
+ return '\n'.join(out)
+
+def get_list(commit_range, git_dir=None, count=None):
+ """Get a log of a list of comments
+
+ This returns the output of 'git log' for the selected commits
+
+ Args:
+ commit_range (str): Range of commits to count (e.g. 'HEAD..base')
+ git_dir (str): Path to git repositiory (None to use default)
+ count (int): Number of commits to list, or None for no limit
+
+ Returns
+ str: String containing the contents of the git log
+ """
+ params = gitutil.LogCmd(commit_range, reverse=True, count=count,
+ git_dir=git_dir)
+ return command.RunPipe([params], capture=True).stdout
def get_metadata_for_list(commit_range, git_dir=None, count=None,
series=None, allow_overwrite=False):
@@ -573,9 +621,7 @@ def get_metadata_for_list(commit_range, git_dir=None, count=None,
if not series:
series = Series()
series.allow_overwrite = allow_overwrite
- params = gitutil.LogCmd(commit_range, reverse=True, count=count,
- git_dir=git_dir)
- stdout = command.RunPipe([params], capture=True).stdout
+ stdout = get_list(commit_range, git_dir, count)
pst = PatchStream(series, is_log=True)
for line in stdout.splitlines():
pst.process_line(line)