diff --git a/drupy/objects.py b/drupy/objects.py index a92da64..0bf85a0 100644 --- a/drupy/objects.py +++ b/drupy/objects.py @@ -373,18 +373,27 @@ class GitRepoApplier(Applier): def __init__(self, runner, config): Applier.__init__(self, runner, config) self.url = config['url'] + self.shallow = config.get('shallow', True) def applyTo(self, target): call = ['git', 'clone', self.url] - if 'branch' in self.config: - call += ['-b', self.config['branch']] + + if self.shallow: + b = self.config.get('revision') or self.config.get('branch') + call += ['--branch', b, '--depth', '1'] + else: + if 'branch' in self.config: + call += ['-b', self.config['branch']] + call.append(target) self.runner.command(call) - if 'revision' in self.config: - wd = os.getcwd() - os.chdir(target) - self.runner.command(['git', 'checkout', self.config['revision']]) - os.chdir(wd) + + if not self.shallow: + if 'revision' in self.config: + wd = os.getcwd() + os.chdir(target) + self.runner.command(['git', 'checkout', self.config['revision']]) + os.chdir(wd) def isValid(self): return self.type == 'git' or 'branch' in self.config \