Skip to content

Instantly share code, notes, and snippets.

@tomleibo
Created June 4, 2018 16:08
Show Gist options
  • Save tomleibo/5b8e0c033223fac126809b3e7a05e68c to your computer and use it in GitHub Desktop.
Save tomleibo/5b8e0c033223fac126809b3e7a05e68c to your computer and use it in GitHub Desktop.
import commands
signature = "22"
statusOutput = commands.getstatusoutput('git show -s --format=%ct HEAD');
if statusOutput[0] is not 0:
print("initial date fetching caused error "+statusOutput[1])
exit()
initialDate = int(statusOutput[1])
date = initialDate
while True:
statusOutput = commands.getstatusoutput('git show -s --format=%H HEAD');
if statusOutput[0] is not 0:
print("fetching commit hash caused error "+statusOutput[1])
exit()
commitHash = statusOutput[1]
if commitHash[0:len(signature)] == signature:
break
date -= 1
amendCommand = 'git commit --amend --no-edit --date "' + str(date) + '"'
statusOutput = commands.getstatusoutput(amendCommand)
if statusOutput[0] is not 0:
print("amending caused error "+statusOutput[1])
exit()
print('date changed by '+str(initialDate - date) + ' millis')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment