I also tried [a-zA-Z]{2,}-\d+ but with the same results
def verify_commit_text(tags):
for line in tags:
if re.match('^NO-TIK',line):
return True
elif re.match('^NO-REVIEW', line):
return True
elif re.match('[a-zA-Z]-[0-9][0-9]', line):
return True
else:
return False
if __name__ == '__main__':
commit_text_verified = verify_commit_text(os.popen('hg tip --template "{desc}"'));
#commit_text_verified = verify_commit_text(os.popen('hg log -r $1 --template "{desc}"'));
if (commit_text_verified):
sys.exit(0)
else:
print >> sys.stderr, ('[obey the rules!]')
sys.exit(1);
if i use a text "JIRA-1234" the regex in :
elif re.match('[a-zA-Z]-[0-9][0-9]', line):
does not seem to work and i get:
[obey the rules!]
on stdout.
The regex is working exactly as you’ve specified it .. it is searching for 1 character and 1 digit. You probably want something like
Further, always prefix regular expression strings with an ‘r’ as in the above. Or it will bite you.