diff options
Diffstat (limited to 'morphlib/git.py')
-rw-r--r-- | morphlib/git.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/morphlib/git.py b/morphlib/git.py index 5f2ca7f6..063ec0e7 100644 --- a/morphlib/git.py +++ b/morphlib/git.py @@ -264,6 +264,12 @@ def is_valid_sha1(ref): return len(ref) == 40 and all(x in string.hexdigits for x in ref) +def clone_into(runcmd, srcpath, targetpath, ref=None): + '''Clones a repo in srcpath into targetpath, optionally directly at ref.''' + if ref is None: + runcmd(['git', 'clone', srcpath, targetpath]) + else: + runcmd(['git', 'clone', '-b', ref, srcpath, targetpath]) def gitcmd(runcmd, *args, **kwargs): '''Run git commands safely''' |