Commit b2d2479a authored by Michal Čihař's avatar Michal Čihař

Commit only unique VCS repos for project

There is no need to repeatedly process linked repositories, we need to
do this just once.

Issue #861
Signed-off-by: default avatarMichal Čihař <michal@cihar.com>
parent defd7651
...@@ -380,7 +380,7 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -380,7 +380,7 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
return False return False
def repo_needs_push(self): def repo_needs_push(self):
for component in self.subproject_set.all(): for component in self.all_repo_components():
if component.repo_needs_push(): if component.repo_needs_push():
return True return True
return False return False
...@@ -391,13 +391,15 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -391,13 +391,15 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
""" """
ret = False ret = False
components = self.all_repo_components()
# Iterate all components # Iterate all components
for component in self.subproject_set.all(): for component in components:
component.commit_pending(request, skip_push=True) component.commit_pending(request, skip_push=True)
# Push all components, this avoids multiple pushes for linked # Push all components, this avoids multiple pushes for linked
# components # components
for component in self.subproject_set.all(): for component in components:
ret |= component.push_if_needed(request, on_commit=on_commit) ret |= component.push_if_needed(request, on_commit=on_commit)
return ret return ret
...@@ -407,7 +409,7 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -407,7 +409,7 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
Updates all git repos. Updates all git repos.
""" """
ret = True ret = True
for component in self.subproject_set.all(): for component in self.all_repo_components():
ret &= component.do_update(request, method=method) ret &= component.do_update(request, method=method)
return ret return ret
...@@ -422,7 +424,7 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin): ...@@ -422,7 +424,7 @@ class Project(models.Model, PercentMixin, URLMixin, PathMixin):
Pushes all git repos. Pushes all git repos.
""" """
ret = False ret = False
for component in self.subproject_set.all(): for component in self.all_repo_components():
ret |= component.do_reset(request) ret |= component.do_reset(request)
return ret return ret
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment