#!/usr/bin/env python # # git-abort-changes # Runs a 'git-clean -d -x -f' and then runs 'git-status' and removes all files # that have been modified and checks them out again. Use with caution. # # David Cantrell # import os if __name__ == "__main__": os.system("git-clean -d -x -f") cmd = os.popen("git-status") status = map(lambda e: e.strip(), cmd.readlines()) cmd.close() for statusline in status: if statusline.find("#\tmodified:") != -1: statusline = statusline.replace("#\tmodified:", "").strip() if os.path.isfile(statusline): os.unlink(statusline) os.system("git-checkout %s" % (statusline,))