#!/usr/bin/env python3
# adapted from http://robjwells.com/post/57241647827/commit-summary-length-hooks

import sys

with open(sys.argv[1]) as message:
    summary = message.readline().rstrip("\n")

if len(summary) > 50:
  def red(s):
    return "\x1b[31m" + s + "\x1b[0m"
  print(summary[:50], red("|" + summary[50:]), sep="")
  print(red("{:>51}".format("commit summary too long |")))
  sys.exit(1)
