Allow overriding clone depth
This changes the default for packages to be unlimited depth, but allows setting the depth on a per project basis. Without this change it's not possible to use a gitref other than 'master'.
This commit is contained in:
parent
4883c99c40
commit
eab330bd89
|
@ -78,7 +78,8 @@ class PackageBuilder(Builder):
|
|||
|
||||
LOG.info("Fetching source code for '%s'", project.name)
|
||||
repo = OpenstackGitRepo(project.giturl, project.name,
|
||||
project.gitref)
|
||||
project.gitref,
|
||||
depth=project.gitdepth)
|
||||
repo.clone(project_src_path)
|
||||
|
||||
# tell package users where this came from
|
||||
|
|
|
@ -30,13 +30,14 @@ LOG = logging.getLogger(__name__)
|
|||
class OpenstackGitRepo(object):
|
||||
|
||||
def __init__(self, url, project=None, branch='master',
|
||||
metadata_cache_dir=None):
|
||||
metadata_cache_dir=None, depth=None):
|
||||
self.url = url
|
||||
self._project = project
|
||||
self.branch = branch
|
||||
self._repo = None
|
||||
self._metadata_cache_dir = metadata_cache_dir
|
||||
self._head_commit = None
|
||||
self._depth = depth
|
||||
|
||||
@property
|
||||
def cloned(self):
|
||||
|
@ -60,7 +61,11 @@ class OpenstackGitRepo(object):
|
|||
|
||||
def clone(self, outdir):
|
||||
LOG.debug("Cloning '%s' to '%s'", self.url, outdir)
|
||||
self._repo = Repo.clone_from(self.url, outdir, recursive=True, depth=1)
|
||||
kwargs = {'recursive': True}
|
||||
if self._depth:
|
||||
LOG.debug("Cloning with depth=%d", self._depth)
|
||||
kwargs['depth'] = self._depth
|
||||
self._repo = Repo.clone_from(self.url, outdir, **kwargs)
|
||||
git = self._repo.git
|
||||
git.checkout(self.branch)
|
||||
self._invalidate_attrs()
|
||||
|
|
|
@ -33,14 +33,15 @@ TEMPLATE_VARS = ('name', 'version', 'gitref', 'stackforge')
|
|||
class OpenstackProject(object):
|
||||
|
||||
def __init__(self, settings, name, version=None, gitref=None, giturl=None,
|
||||
venv_command=None, install_command=None, install_path=None,
|
||||
package_name=None, stackforge=False, system_dependencies=[],
|
||||
pip_dependencies=[]):
|
||||
gitdepth=None, venv_command=None, install_command=None,
|
||||
install_path=None, package_name=None, stackforge=False,
|
||||
system_dependencies=[], pip_dependencies=[]):
|
||||
self._settings = settings
|
||||
self.name = name
|
||||
self._version = version
|
||||
self._gitref = gitref
|
||||
self._giturl = giturl
|
||||
self.gitdepth = gitdepth
|
||||
self._venv_command = venv_command
|
||||
self._install_command = install_command
|
||||
self._install_path = install_path
|
||||
|
|
Loading…
Reference in New Issue