Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #coding=utf-8
- import sys
- import re
- import subprocess
- def main():
- line = sys.stdin.read()
- base, commit, ref = line.strip().split()
- new_branch_push = re.match(r'[^1-9]+', base)
- branch_deleted = re.match(r'[^1-9]+', commit)
- contains_commit_msg = False
- if not new_branch_push:
- revs = base + "..." + commit
- proc = subprocess.Popen(['git', 'rev-list','--oneline','--first-parent', revs], stdout=subprocess.PIPE)
- lines = proc.stdout.readlines()
- if lines:
- for line in lines:
- rev = str(line)
- match = re.search(r'TICKET-[0-9]{2,5}|#TICKET-[0-9]{2,5}|HOTFIX|FORCE', rev)
- if match is not None:
- contains_commit_msg = True
- if contains_commit_msg or new_branch_push or branch_deleted:
- exit(0)
- else:
- print "Commit does not contain the story associated with the commit in the format: TICKET-123 or #TICKET-123"
- exit(1)
- if __name__ == "__main__"
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement