clone.py 685 B

12345678910111213141516171819202122232425262728293031323334
  1. """Clone.
  2. This trivial script demonstrates how to clone or lock a remote repository.
  3. Example usage:
  4. 1. python examples/clone.py git://github.com/jelmer/dulwich
  5. 2. python examples/clone.py git://github.com/jelmer/dulwich.git dulwich
  6. """
  7. import sys
  8. from os.path import basename
  9. from getopt import getopt
  10. from dulwich import porcelain
  11. _, args = getopt(sys.argv, "", [])
  12. if len(args) < 2:
  13. print("usage: %s host:path path" % (args[0], ))
  14. sys.exit(1)
  15. elif len(args) < 3:
  16. target_path = basename(args[1].split(":")[-1])
  17. if target_path[-4:] == ".git":
  18. target_path = target_path[:-4]
  19. else:
  20. target_path = args[2]
  21. porcelain.clone(args[1], target_path)