Skip to content

Commit

Permalink
Merge pull request #115 from datawire/rhs/bug/109
Browse files Browse the repository at this point in the history
real fix for #109
  • Loading branch information
rhs committed Dec 1, 2017
2 parents 24fe560 + f7e6c77 commit 7e867ae
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 6 deletions.
4 changes: 3 additions & 1 deletion forge/cli.py
Expand Up @@ -182,7 +182,9 @@ def pull(forge):
"""
Do a git pull on all services.
"""
forge.execute(forge.pull)
# XXX: should have a better way to track this, but this is quick
pulled = {}
forge.execute(lambda svc: forge.pull(svc, pulled))

@forge.command()
@click.pass_obj
Expand Down
4 changes: 2 additions & 2 deletions forge/core.py
Expand Up @@ -242,9 +242,9 @@ def deploy(self, service, k8s_dir):
self.deployed.append((service, k8s_dir))

@task()
def pull(self, service):
def pull(self, service, pulled):
with task.verbose(True):
service.pull()
service.pull(pulled)

def load_config(self):
if not self.config:
Expand Down
14 changes: 11 additions & 3 deletions forge/service.py
Expand Up @@ -220,7 +220,13 @@ def __init__(self, forge, descriptor, shallow=False):
self._info = None
self._version = None
self.shallow = shallow
self.is_git = is_git(self.root)
gitdir = util.search_parents(".git", self.root)
if gitdir:
self.gitroot = os.path.dirname(gitdir)
self.is_git = True
else:
self.gitroot = None
self.is_git = False
if forge.branch:
self.branch = branch
elif self.is_git:
Expand Down Expand Up @@ -256,9 +262,11 @@ def image(self, container):


@task()
def pull(self):
def pull(self, pulled):
if self.is_git and self.shallow:
sh("git", "pull", "--update-shallow", cwd=self.root)
if self.gitroot not in pulled:
pulled[self.gitroot] = True
sh("git", "pull", "--update-shallow", cwd=self.gitroot)

def metadata(self, registry, repo):
metadata = OrderedDict()
Expand Down
13 changes: 13 additions & 0 deletions forge/tests/blackbox/concurrent-clones/test.spec
@@ -0,0 +1,13 @@
RUN git clone https://github.com/forge-playground/development-environment.git
CWD development-environment
RUN git checkout 6cbb3313b8c9e132b5e674325df04cae9eac04fa
RUN forge pull
OUT cloning
OUT cloning
OUT cloning
OUT cloning
OUT git pull --update-shallow
OUT git pull --update-shallow
OUT git pull --update-shallow
OUT git pull --update-shallow
NOT git pull

0 comments on commit 7e867ae

Please sign in to comment.