kriti21

Untitled

Apr 11th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.32 KB | None | 0 0
  1.         revert_shortlog_regex = re.compile('^Revert\s\"[\S+\s*]*\"')
  2.         headline_regex = re.compilere.compile('^This reverts commit [0-9a-f]{40}')
  3.         sha_regex = re.compile(r'\b[0-9a-f]{40}\b')
  4.         if not allow_revert_commits and revert_shortlog_regex.match(shortlog):
  5.            
  6.             reverted_shortlog = shortlog.lstrip('Revert ')
  7.             # verify this reverted shortlog
  8.  
  9.             if len(body) != 0:
  10.                 body = body.strip('\n')
  11.                 blankline = body.find('\n\n')
  12.                 headline = body[:blankline] if blankline != -1 else body
  13.                
  14.                 if headline_regex.match(headline):
  15.                     commit_sha = re.search(sha_regex, headline)
  16.                     commit_sha = commit_sha.group(0)
  17.                     # verify commit sha and corresponding shortlog
  18.                
  19.                 reason = body[blankline+1:] if blankline != -1 else ''
  20.                
  21.                 if len(reason) == 0:
  22.                     yield Result(self, 'Revert commit does not have a reason.')
  23.  
  24.                 elif len(reason) > 50:
  25.                     yield Result(self, 'Reason of revert commit contains too long lines.')
  26.  
  27.             else:
  28.                 yield Result(self, 'Revert commit does not have a reason.')
  29.            
  30.             return
Add Comment
Please, Sign In to add comment