Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

Commit

Permalink
Allow params for clone method
Browse files Browse the repository at this point in the history
This commit adds a depth param to clone method which can be used to create shallow clones.
  • Loading branch information
sonicaj committed Jun 19, 2019
1 parent 8ac39e5 commit 6673aa8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions iocage_lib/ioc_plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def __init__(self, release=None, jail=None, plugin=None, branch=None,
# Backwards compat
self.branch = 'master'

def clone_repo(self):
def clone_repo(self, depth=None):
if self.server == "download.freebsd.org":
git_server = "https://github.com/freenas/iocage-ix-plugins.git"
else:
Expand All @@ -94,7 +94,7 @@ def clone_repo(self):

if os.geteuid() == 0:
try:
self.__clone_repo(git_server, git_working_dir)
self.__clone_repo(git_server, git_working_dir, depth)
except Exception as err:
iocage_lib.ioc_common.logit(
{
Expand Down Expand Up @@ -1403,7 +1403,7 @@ def __fetch_release__(self, release):
fetch_args = {'release': release, 'eol': False}
iocage_lib.iocage.IOCage(silent=self.silent).fetch(**fetch_args)

def __clone_repo(self, repo_url, destination):
def __clone_repo(self, repo_url, destination, depth=None):
"""
This is to replicate the functionality of cloning/pulling a repo
"""
Expand Down Expand Up @@ -1438,8 +1438,11 @@ def __clone_repo(self, repo_url, destination):
except FileNotFoundError:
pass
finally:
kwargs = {'env': os.environ.copy(), 'depth': depth}
repo = git.Repo.clone_from(
repo_url, destination, env=os.environ.copy()
repo_url, destination, **{
k: v for k, v in kwargs.items() if v
}
)
origin = repo.remotes.origin

Expand Down

0 comments on commit 6673aa8

Please sign in to comment.