(url, dstpath, branch, remote_name='origin')
| 791 | |
| 792 | |
| 793 | def git_clone(url, dstpath, branch, remote_name='origin'): |
| 794 | debug_print(f'git_clone(url={url}, dstpath={dstpath})') |
| 795 | if os.path.isdir(os.path.join(dstpath, '.git')): |
| 796 | remotes = get_git_remotes(dstpath) |
| 797 | if remote_name in remotes: |
| 798 | debug_print(f'Repository {url} with remote "{remote_name}" already cloned to directory {dstpath}, skipping.') |
| 799 | return True |
| 800 | else: |
| 801 | debug_print(f'Repository {url} with remote "{remote_name}" already cloned to directory {dstpath}, but remote has not yet been added. Creating.') |
| 802 | return run([GIT(), 'remote', 'add', remote_name, url], cwd=dstpath) == 0 |
| 803 | |
| 804 | mkdir_p(dstpath) |
| 805 | git_clone_args = ['--recurse-submodules', '--branch', branch] # Do not check out a branch (installer will issue a checkout command right after) |
| 806 | if GIT_CLONE_SHALLOW: |
| 807 | git_clone_args += ['--depth', '1'] |
| 808 | print(f'Cloning from {url}...') |
| 809 | return run([GIT(), 'clone', '-o', remote_name, *git_clone_args, url, dstpath]) == 0 |
| 810 | |
| 811 | |
| 812 | def git_pull(repo_path, branch_or_tag, remote_name='origin'): |
no test coverage detected