Skip to content

Commit

Permalink
Merge pull request #2 from moreonion/git-depth-1
Browse files Browse the repository at this point in the history
Use shallow copies for git checkouts.
  • Loading branch information
torotil authored Apr 29, 2017
2 parents b81b14d + 2bff7ba commit e7c0e99
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions drupy/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit e7c0e99

Please sign in to comment.