Style note:  try: except (Ask forgiveness) is more pythonic than if: then (look before you leap) when one of the paths is "the right way" (in this case, the way git messages are expected to look from now on).  Historically, that seems to have come about because try: except is quicker than if: then when the except clause is not triggered.  This could be written as a try: except KeyError: if you wanted to follow that.