chiark / gitweb /
squash: Make commit message editing more convenient
[stgit] / stgit / utils.py
index 1fa96c252f3af6646229a931668621e4e44524f6..5c0e15937edf9b008976279f4fcfcff6cf22598a 100644 (file)
@@ -200,6 +200,16 @@ def edit_string(s, filename):
     os.remove(filename)
     return s
 
+def append_comment(s, comment, separator = '---'):
+    return ('%s\n\n%s\nEverything following the line with "%s" will be'
+            ' ignored\n\n%s' % (s, separator, separator, comment))
+
+def strip_comment(s, separator = '---'):
+    try:
+        return s[:s.index('\n%s\n' % separator)]
+    except ValueError:
+        return s
+
 def find_patch_name(patchname, unacceptable):
     """Find a patch name which is acceptable."""
     if unacceptable(patchname):