Advertisement
Guest User

Untitled

a guest
Aug 24th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #coding=utf-8
  3.  
  4. import sys
  5. import re
  6. import subprocess
  7.  
  8.  
  9.  
  10. def main():
  11. line = sys.stdin.read()
  12. base, commit, ref = line.strip().split()
  13. new_branch_push = re.match(r'[^1-9]+', base)
  14. branch_deleted = re.match(r'[^1-9]+', commit)
  15. contains_commit_msg = False
  16. if not new_branch_push:
  17. revs = base + "..." + commit
  18. proc = subprocess.Popen(['git', 'rev-list','--oneline','--first-parent', revs], stdout=subprocess.PIPE)
  19. lines = proc.stdout.readlines()
  20. if lines:
  21. for line in lines:
  22. rev = str(line)
  23. match = re.search(r'TICKET-[0-9]{2,5}|#TICKET-[0-9]{2,5}|HOTFIX|FORCE', rev)
  24. if match is not None:
  25. contains_commit_msg = True
  26. if contains_commit_msg or new_branch_push or branch_deleted:
  27. exit(0)
  28. else:
  29. print "Commit does not contain the story associated with the commit in the format: TICKET-123 or #TICKET-123"
  30. exit(1)
  31.  
  32. if __name__ == "__main__"
  33. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement