2
0

latest_change.py 531 B

123456789101112131415161718192021
  1. #!/usr/bin/python
  2. # Example printing the last author of a specified file
  3. import sys
  4. import time
  5. from dulwich.repo import Repo
  6. if len(sys.argv) < 2:
  7. print("usage: %s filename" % (sys.argv[0], ))
  8. sys.exit(1)
  9. r = Repo(".")
  10. w = r.get_walker(paths=[sys.argv[1]], max_entries=1)
  11. try:
  12. c = next(iter(w)).commit
  13. except StopIteration:
  14. print("No file %s anywhere in history." % sys.argv[1])
  15. else:
  16. print("%s was last changed by %s at %s (commit %s)" % (
  17. sys.argv[1], c.author, time.ctime(c.author_time), c.id))