]> Git Repo - J-u-boot.git/blobdiff - tools/patman/patchstream.py
patman: Add a test for PatchStream tags
[J-u-boot.git] / tools / patman / patchstream.py
index cf591b27573f288d28e344b3d08589a5465c4e1a..d6f6ae9251303778f33e8a50cdc3205455541dab 100644 (file)
@@ -5,6 +5,7 @@
 """Handles parsing a stream of commits/emails from 'git log' or other source"""
 
 import datetime
+import io
 import math
 import os
 import re
@@ -81,6 +82,28 @@ class PatchStream:
         self.state = STATE_MSG_HEADER    # What state are we in?
         self.commit = None               # Current commit
 
+    @staticmethod
+    def process_text(text, is_comment=False):
+        """Process some text through this class using a default Commit/Series
+
+        Args:
+            text (str): Text to parse
+            is_comment (bool): True if this is a comment rather than a patch.
+                If True, PatchStream doesn't expect a patch subject at the
+                start, but jumps straight into the body
+
+        Returns:
+            PatchStream: object with results
+        """
+        pstrm = PatchStream(Series())
+        pstrm.commit = commit.Commit(None)
+        infd = io.StringIO(text)
+        outfd = io.StringIO()
+        if is_comment:
+            pstrm.state = STATE_PATCH_HEADER
+        pstrm.process_stream(infd, outfd)
+        return pstrm
+
     def _add_warn(self, warn):
         """Add a new warning to report to the user about the current commit
 
This page took 0.02709 seconds and 4 git commands to generate.