From dd134813921499946a6c05a859c0c5bc6fa84473 Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Fri, 2 Nov 2007 07:24:55 +0000 Subject: [PATCH] =?utf8?q?Add=20a=20check=20for=20redundant=20cd=20"${S}"?= =?utf8?q?=20statements=20on=20the=20first=20line=20of=20src=5F(compile|in?= =?utf8?q?stall|test)=20ebuild=20methods.=20Thanks=20to=20Petteri=20R?= =?utf8?q?=C3=A4ty=20=20for=20this=20patch.=20(trun?= =?utf8?q?k=20r8351=20and=20r8353)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit svn path=/main/branches/2.1.2/; revision=8376 --- bin/repoman | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/bin/repoman b/bin/repoman index 328aec4ec..84033318a 100755 --- a/bin/repoman +++ b/bin/repoman @@ -836,6 +836,28 @@ class EbuildUselessDodoc(object): (match.group(2), ) + " on line: %d")) return errors +class EbuildUselessCdS(object): + """Check for redundant cd ${S} statements""" + repoman_check_name = 'ebuild.minorsyn' + method_re = re.compile(r'^\s*src_(compile|install|test)\s*\(\)') + cds_re = re.compile(r'^\s*cd\s+("\$(\{S\}|S)"|\$(\{S\}|S))\s') + + def __init__(self, contents): + self.contents = contents + + def Run(self): + errors = [] + check_next_line = False + for num, line in enumerate(self.contents): + if check_next_line: + check_next_line = False + if self.cds_re.match(line): + errors.append((num + 1, + 'Ebuild has redundant cd ${S} statement on line: %d')) + elif self.method_re.match(line): + check_next_line = True + return errors + if mymode == "commit": retval = ("","") if isCvs: @@ -1459,7 +1481,7 @@ for x in scanlist: finally: f.close() del f - for check in (EbuildQuote, EbuildUselessDodoc): + for check in (EbuildQuote, EbuildUselessDodoc, EbuildUselessCdS): c = check(contents) errors = c.Run() for e in errors: -- 2.26.2