def once_git_check_commit_title():
 subp = subprocess.Popen(['git', 'log', '--no-merges', '--pretty=%s', '-1'], stdout=subprocess.PIPE)
 title = subp.communicate()[0]
 if subp.returncode:
  raise Exception(('git log failed with code %s' % subp.returncode))
 git_keywords = '(I[0-9a-f]{8,40})|([Bb]ug|[Ll][Pp])[\\s\\#:]*(\\d+)|([Bb]lue[Pp]rint|[Bb][Pp])[\\s\\#:]*([A-Za-z0-9\\-]+)'
 GIT_REGEX = re.compile(git_keywords)
 error = False
 if ((GIT_REGEX.search(title) is not None) and (len(title.split()) <= 3)):
  print ("N801: git commit title ('%s') should provide an accurate description of the change, not just a reference to a bug or blueprint" % title.strip())
  error = True
 if (len(title.decode('utf-8')) > 72):
  print ("N802: git commit title ('%s') should be under 50 chars" % title.strip())
  error = True
 return error

def once_git_check_commit_title ( ) : subp = subprocess . Popen ( [ 'git' , 'log' , '--no-merges' , '--pretty=%s' , '-1' ] , stdout = subprocess . PIPE ) title = subp . communicate ( ) [ 0 ] if subp . returncode : raise Exception ( ( 'git log failed with code %s' % subp . returncode ) ) git_keywords = '(I[0-9a-f]{8,40})|([Bb]ug|[Ll][Pp])[\\s\\#:]*(\\d+)|([Bb]lue[Pp]rint|[Bb][Pp])[\\s\\#:]*([A-Za-z0-9\\-]+)' GIT_REGEX = re . compile ( git_keywords ) error = False if ( ( GIT_REGEX . search ( title ) is not None ) and ( len ( title . split ( ) ) <= 3 ) ) : print ( "N801: git commit title ('%s') should provide an accurate description of the change, not just a reference to a bug or blueprint" % title . strip ( ) ) error = True if ( len ( title . decode ( 'utf-8' ) ) > 72 ) : print ( "N802: git commit title ('%s') should be under 50 chars" % title . strip ( ) ) error = True return error
check git commit messages .