Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- revert_shortlog_regex = re.compile('^Revert\s\"[\S+\s*]*\"')
- headline_regex = re.compilere.compile('^This reverts commit [0-9a-f]{40}')
- sha_regex = re.compile(r'\b[0-9a-f]{40}\b')
- if not allow_revert_commits and revert_shortlog_regex.match(shortlog):
- reverted_shortlog = shortlog.lstrip('Revert ')
- # verify this reverted shortlog
- if len(body) != 0:
- body = body.strip('\n')
- blankline = body.find('\n\n')
- headline = body[:blankline] if blankline != -1 else body
- if headline_regex.match(headline):
- commit_sha = re.search(sha_regex, headline)
- commit_sha = commit_sha.group(0)
- # verify commit sha and corresponding shortlog
- reason = body[blankline+1:] if blankline != -1 else ''
- if len(reason) == 0:
- yield Result(self, 'Revert commit does not have a reason.')
- elif len(reason) > 50:
- yield Result(self, 'Reason of revert commit contains too long lines.')
- else:
- yield Result(self, 'Revert commit does not have a reason.')
- return
Add Comment
Please, Sign In to add comment