Commit c0b718bf authored by Boxiang Sun's avatar Boxiang Sun

testnode: Update repo's submodule when running testnode

Also reset the submodule when rollback the main module
And ignore corrupt repo when updating submodule
parent ca229c3e
......@@ -164,6 +164,15 @@ class Updater(object):
logger.exception("")
if not(correct_url):
self.deleteRepository()
else:
# Get the submodule only if we are in the correct repo
try:
parameter_list = ['submodule', 'update', '--init']
self._git(*parameter_list)
except SubprocessError:
# If working on a corrupt repository, just ignore it
logger.exception("")
if not os.path.exists(self.repository_path):
parameter_list = ['clone', self.url]
if self.branch is not None:
......@@ -184,12 +193,28 @@ class Updater(object):
else:
h = revision[1]
if h != self._git('rev-parse', 'HEAD'):
self._git('clean', '-fdx')
try:
self._git('clean', '-fdx')
self._git('submodule', 'foreach', '--recursive', self.git_binary, 'clean', '-fdx')
except SubprocessError:
logger.exception("")
# For performance, it is ok to use 'git reset --hard',
# theses days it is not slow like it was long time ago.
self._git('reset', '--hard', h)
try:
self._git('submodule', 'foreach', '--recursive', self.git_binary, 'reset', '--hard')
self._git('submodule', 'update', '--init', '--recursive')
except SubprocessError:
logger.exception("")
else:
self._git('clean', '-fdx')
try:
self._git('clean', '-fdx')
self._git('submodule', 'foreach', '--recursive', self.git_binary, 'clean', '-fdx')
except SubprocessError:
logger.exception("")
if os.path.exists('.git/svn'):
self._git('svn', 'rebase')
else:
......@@ -202,6 +227,8 @@ class Updater(object):
self._git('checkout', 'origin/%s' % self.branch, '-b',
self.branch)
self._git('reset', '--hard', '@{u}')
self._git('submodule', 'foreach', '--recursive', self.git_binary, 'reset', '--hard')
self._git('submodule', 'update', '--init', '--recursive')
self.revision = self._git_find_rev(self._git('rev-parse', 'HEAD'))
elif self.getRepositoryType() == SVN_TYPE:
# following code allows sparse checkout
......
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