1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# SPDX-License-Identifier: Apache-2.0 OR GPL-2.0-or-later
"""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
3. python examples/clone.py git://github.com/jelmer/dulwich.git dulwich
"""
import sys
from getopt import getopt
from os.path import basename
from dulwich import porcelain
_, args = getopt(sys.argv, "", [])
if len(args) < 2:
print(f"usage: {args[0]} host:path path")
sys.exit(1)
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)
|