Page MenuHomeSoftware Heritage

No OneTemporary

diff --git a/examples/clone.py b/examples/clone.py
index c14fa9f9..f91c55df 100644
--- a/examples/clone.py
+++ b/examples/clone.py
@@ -1,18 +1,34 @@
-#!/usr/bin/python
-# This trivial script demonstrates how to clone a remote repository.
-#
-# Example usage:
-# python examples/clone.py git://github.com/jelmer/dulwich dulwich-clone
+"""Clone.
+
+This trivial script demonstrates how to clone or lock a remote repository.
+
+Example usage:
+ 1. python examples/clone.py git://github.com/jelmer/dulwich
+ 2. python examples/clone.py git://github.com/jelmer/dulwich.git dulwich
+"""
+
import sys
+
+from os.path import basename
+
from getopt import getopt
+
from dulwich import porcelain
-opts, args = getopt(sys.argv, "", [])
-opts = dict(opts)
+
+_, args = getopt(sys.argv, "", [])
+
if len(args) < 2:
print("usage: %s host:path path" % (args[0], ))
sys.exit(1)
-porcelain.clone(args[1], args[2])
+elif len(args) < 3:
+ target_path = basename(args[1].split(":")[-1])
+ if target_path[-4:] == ".git":
+ target_path = target_path[:-4]
+else:
+ target_path = args[2]
+
+porcelain.clone(args[1], target_path)

File Metadata

Mime Type
text/x-diff
Expires
Sat, Jun 21, 5:27 PM (1 w, 6 d ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
3305758

Event Timeline