Merge "Gracefully handle broken .gitmodule files"
This commit is contained in:
@@ -181,6 +181,23 @@ class TestMergerRepo(ZuulTestCase):
|
||||
# And now reset the repo again. This should not crash
|
||||
work_repo.reset()
|
||||
|
||||
def test_broken_gitmodules(self):
|
||||
parent_path = os.path.join(self.upstream_root, 'org/project1')
|
||||
work_repo = Repo(parent_path, self.workspace_root,
|
||||
'none@example.org', 'User Name', '0', '0')
|
||||
self.waitUntilSettled()
|
||||
|
||||
# Break the gitmodules
|
||||
path = work_repo.local_path
|
||||
with open(os.path.join(path, '.gitmodules'), 'w') as f:
|
||||
f.write('[submodule "libfoo"]\n'
|
||||
'path = include/foo\n'
|
||||
'---\n'
|
||||
'url = git://example.com/git/lib.git')
|
||||
|
||||
# And now reset the repo again. This should not crash
|
||||
work_repo.reset()
|
||||
|
||||
|
||||
class TestMergerWithAuthUrl(ZuulTestCase):
|
||||
config_file = 'zuul-github-driver.conf'
|
||||
|
||||
@@ -157,7 +157,15 @@ class Repo(object):
|
||||
break
|
||||
except Exception as e:
|
||||
if attempt < self.retry_attempts:
|
||||
time.sleep(self.retry_interval)
|
||||
if 'fatal: bad config' in e.stderr:
|
||||
# This error can be introduced by a merge conflict
|
||||
# in the .gitmodules which was left by the last
|
||||
# merge operation. In this case reset and clean
|
||||
# the repo and try again immediately.
|
||||
reset_repo_to_head(repo)
|
||||
repo.git.clean('-x', '-f', '-d')
|
||||
else:
|
||||
time.sleep(self.retry_interval)
|
||||
self.log.exception("Retry %s: Fetch %s %s %s" % (
|
||||
attempt, self.local_path, remote, ref))
|
||||
self._ensure_cloned()
|
||||
|
||||
Reference in New Issue
Block a user