Skip to content

Instantly share code, notes, and snippets.

@goyalmohit
Created April 14, 2019 13:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save goyalmohit/15d8fc66f08e908ea7d2c17d5cdfe750 to your computer and use it in GitHub Desktop.
Save goyalmohit/15d8fc66f08e908ea7d2c17d5cdfe750 to your computer and use it in GitHub Desktop.
Python script for post commit git hook to clear .retry files
#!/usr/bin/env python
import sys, os, re
from subprocess import check_output
# Collect the parameters
previous_head = sys.argv[1]
new_head = sys.argv[2]
is_branch_checkout = sys.argv[3]
if is_branch_checkout == "0":
print "post-checkout: This is a file checkout. Nothing to do."
sys.exit(0)
print "post-checkout: Deleting all '.retry' files in working directory"
for root, dirs, files in os.walk('.'):
for filename in files:
ext = os.path.splitext(filename)[1]
if ext == '.retry':
os.unlink(os.path.join(root, filename))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment