Lines Matching +full:line +full:- +full:name

3 # SPDX-License-Identifier:	GPL-2.0+
18 re_remove = re.compile('^BUG=|^TEST=|^BRANCH=|^Change-Id:|^Review URL:'
19 '|Reviewed-on:|Commit-\w*:')
21 # Lines which are allowed after a TEST= line
22 re_allowed_after_test = re.compile('^Signed-off-by:')
25 re_signoff = re.compile('^Signed-off-by: *(.*)')
28 re_cover = re.compile('^Cover-letter:')
31 re_cover_cc = re.compile('^Cover-letter-cc: *(.*)')
34 re_series_tag = re.compile('^Series-([a-z-]*): *(.*)')
37 re_commit_tag = re.compile('^Commit-([a-z-]*): *(.*)')
40 re_tag = re.compile('^(Tested-by|Acked-by|Reviewed-by|Patch-cc): (.*)')
43 re_commit = re.compile('^commit ([0-9a-f]*)$')
48 # States we can be in - can we use range() and still have comments?
50 STATE_PATCH_SUBJECT = 1 # In patch subject (first line of log for a commit)
52 STATE_DIFFS = 3 # In the diff part (past --- line)
62 def __init__(self, series, name=None, is_log=False): argument
63 self.skip_blank = False # True to skip a single blank line
64 self.found_test = False # Found a TEST= line
67 self.linenum = 1 # Output line number we are up to
68 self.in_section = None # Name of start...END section we are in
73 self.in_change = 0 # Non-zero if we are in a change list
76 self.signoff = [] # Contents of signoff line
79 def AddToSeries(self, line, name, value): argument
80 """Add a new Series-xxx tag.
82 When a Series-xxx tag is detected, we come here to record it, if we
86 line: Source line containing tag (useful for debug/error messages)
87 name: Tag name (part after 'Series-')
88 value: Tag value (part after 'Series-xxx: ')
90 if name == 'notes':
91 self.in_section = name
94 self.series.AddTag(self.commit, line, name, value)
96 def AddToCommit(self, line, name, value): argument
97 """Add a new Commit-xxx tag.
99 When a Commit-xxx tag is detected, we come here to record it.
102 line: Source line containing tag (useful for debug/error messages)
103 name: Tag name (part after 'Commit-')
104 value: Tag value (part after 'Commit-xxx: ')
106 if name == 'notes':
107 self.in_section = 'commit-' + name
115 # If 'END' is missing in a 'Cover-letter' section, and that section
124 def ProcessLine(self, line): argument
125 """Process a single line of a patch file or commit log
127 This process a line and returns a list of lines to output. The list
143 line: text line to process
148 # Initially we have no output. Prepare the input line string
150 line = line.rstrip('\n')
152 commit_match = re_commit.match(line) if self.is_log else None
155 if line[:4] == ' ':
156 line = line[4:]
159 series_tag_match = re_series_tag.match(line)
160 commit_tag_match = re_commit_tag.match(line)
161 cover_match = re_cover.match(line)
162 cover_cc_match = re_cover_cc.match(line)
163 signoff_match = re_signoff.match(line)
166 tag_match = re_tag.match(line)
167 is_blank = not line.strip()
174 # It has its own line with a Subject: tag
193 elif self.in_section == 'commit-notes':
201 # but we are already in a change list, that means a blank line
204 self.warn.append("Missing 'blank line' in section 'Series-changes'")
209 if line == 'END':
215 elif self.in_section == 'commit-notes':
224 self.section.append(line)
228 self.commit.subject = line
231 elif re_remove.match(line) and not commit_tag_match:
236 if line.startswith('TEST='):
248 self.AddToSeries(line, 'cover-cc', value)
253 # Blank line ends this change list
255 elif line == '---':
257 out = self.ProcessLine(line)
260 self.series.AddChange(self.in_change, self.commit, line)
263 # Detect Series-xxx tags
265 name = series_tag_match.group(1)
267 if name == 'changes':
273 (self.commit.hash, line))
276 self.AddToSeries(line, name, value)
279 # Detect Commit-xxx tags
281 name = commit_tag_match.group(1)
283 if name == 'notes':
284 self.AddToCommit(line, name, value)
294 # Remove Tested-by self, since few will take much notice
295 if (tag_match.group(1) == 'Tested-by' and
296 tag_match.group(2).find(os.getenv('USER') + '@') != -1):
297 self.warn.append("Ignoring %s" % line)
298 elif tag_match.group(1) == 'Patch-cc':
301 out = [line]
307 out = [line]
309 # Well that means this is an ordinary line
312 m = re_space_before_tab.match(line)
314 self.warn.append('Line %d/%d has space before tab' %
317 # OK, we have a valid non-blank line
318 out = [line]
326 elif line == '---':
332 out += [line]
337 if not re_allowed_after_test.match(line):
361 re_fname = re.compile('diff --git a/(.*) b/.*')
363 line = infd.readline()
364 if not line:
366 out = self.ProcessLine(line)
369 for line in out:
370 match = re_fname.match(line)
374 if line == '+':
377 if self.blank_count and (line == '-- ' or match):
378 self.warn.append("Found possible blank line(s) at "
381 outfd.write(line + '\n')
410 for line in stdout.splitlines():
411 ps.ProcessLine(line)
435 for line in text.splitlines():
436 ps.ProcessLine(line)
480 backup_dir = None #tempfile.mkdtemp('clean-patch')
509 for line in lines:
510 if line.startswith('Subject:'):
514 line = 'Subject: [%s %s/%d] %s\n' % (prefix, zero, count, text[0])
517 elif line.startswith('*** BLURB HERE ***'):
519 line = '\n'.join(text[1:]) + '\n'
521 line += '\n'.join(series.notes) + '\n'
525 line += '\n' + '\n'.join(out)
526 fd.write(line)