Skip to content

Commit

Permalink
Git: Do 'submoduly sync' before 'submodule update'
Browse files Browse the repository at this point in the history
See 'git submodule sync' man page:
"This is useful when submodule URLs change upstream
and you need to update your local repositories accordingly."

Fixes #2155
  • Loading branch information
krf committed Apr 2, 2015
1 parent fac6452 commit 2b0dda1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
9 changes: 9 additions & 0 deletions master/buildbot/steps/source/git.py
Expand Up @@ -228,12 +228,14 @@ def incremental(self):
else:
yield self._fetchOrFallback()

yield self._syncSubmodule(None)
yield self._updateSubmodule(None)

def clean(self):
command = ['clean', '-f', '-f', '-d']
d = self._dovccmd(command)
d.addCallback(self._fetchOrFallback)
d.addCallback(self._syncSubmodule)
d.addCallback(self._updateSubmodule)
d.addCallback(self._cleanSubmodule)
return d
Expand All @@ -254,6 +256,7 @@ def fresh(self):
else:
yield self._doClobber()
yield self._fullCloneOrFallback()
yield self._syncSubmodule()
yield self._updateSubmodule()
yield self._cleanSubmodule()

Expand Down Expand Up @@ -511,6 +514,12 @@ def computeSourceRevision(self, changes):
return None
return changes[-1].revision

def _syncSubmodule(self, _=None):
if self.submodules:
return self._dovccmd(['submodule', 'sync'])
else:
return defer.succeed(0)

def _updateSubmodule(self, _=None):
if self.submodules:
return self._dovccmd(['submodule', 'update',
Expand Down
3 changes: 3 additions & 0 deletions master/buildbot/test/unit/test_steps_source_git.py
Expand Up @@ -930,6 +930,9 @@ def test_mode_full_fresh_submodule(self):
ExpectShell(workdir='wkdir',
command=['git', 'reset', '--hard', 'FETCH_HEAD', '--'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'submodule', 'sync'])
+ 0,
ExpectShell(workdir='wkdir',
command=['git', 'submodule', 'update', '--init', '--recursive', '--force'])
+ 0,
Expand Down
2 changes: 2 additions & 0 deletions master/docs/relnotes/index.rst
Expand Up @@ -95,6 +95,8 @@ Fixes
* :bb:step:`MasterShellCommand` now correctly logs the working directory where it was run.
* With Git(), force the updating submodules to ensure local changes by the build are overwitten.
This both ensures more consistent builds and avoids errors when updating submodules.
* With Git(), make sure 'git submodule sync' is called before 'git submodule update' to update
stale remote urls (:bb:bug:`2155`).

Deprecations, Removals, and Non-Compatible Changes
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Expand Down

0 comments on commit 2b0dda1

Please sign in to comment.