Commit ce3ce341 authored by Sebastien Robin's avatar Sebastien Robin

testnode: make code more robust when checkout git files

parent 71677792
......@@ -356,6 +356,35 @@ ignore-ssl-certificate = true
finally:
Updater.deleteRepository = original_deleteRepository
def test_05d_LocalModifcationOnRepository(self):
"""
It could happen that there is local modification to to either bug of
git or any manual operation.
Testnode must be able reset the repository to make sure we have no failures
when updating repository
"""
commit_dict = self.generateTestRepositoryList(add_third_repository=True)
test_node = self.getTestNode()
node_test_suite = test_node.getNodeTestSuite('foo')
self.updateNodeTestSuiteData(node_test_suite)
rev_list = test_node.getAndUpdateFullRevisionList(node_test_suite)
self.assertEquals(2, len(rev_list))
self.assertEquals(2, len(node_test_suite.vcs_repository_list))
rep0_clone_path = [x['repository_path'] for x in \
node_test_suite.vcs_repository_list \
if x['repository_path'].endswith("rep0")][0]
my_file = open(os.path.join(rep0_clone_path, 'first_file'), 'w')
my_file.write("next_content")
my_file.close()
# make sure code still works
rev_list = test_node.getAndUpdateFullRevisionList(node_test_suite)
self.assertEqual(2, len(rev_list))
self.assertEqual(2, len(node_test_suite.vcs_repository_list))
# and check local change was resetted
my_file = open(os.path.join(rep0_clone_path, 'first_file'), 'r')
self.assertEqual("initial_content0", my_file.read())
my_file.close()
def test_06_checkRevision(self):
"""
Check if we are able to restore older commit hash if master decide so
......
......@@ -210,8 +210,8 @@ class Updater(object):
self._git('branch', '-D', self.branch)
self._git('checkout', 'origin/%s' % self.branch, '-b',
self.branch)
self._git('update-index', '--refresh') # see note above
self._git('reset', '--merge', '@{u}')
self._git('reset', '--hard', '@{u}')
self._git('clean', '-fdx')
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