Commit 169f89d1 authored by Ayush Tiwari's avatar Ayush Tiwari

Cleanup gitclone and remove useless --recurse-submodule while fetching

parent a968e4bb
......@@ -391,7 +391,7 @@ Then, when update occurs, nothing is done::
Unable to update:
Traceback (most recent call last):
...
...CalledProcessError: Command '['git', 'fetch', '--recurse-submodules', '--all']' returned non-zero exit status 1
...CalledProcessError: Command '['git', 'fetch', '--all']' returned non-zero exit status 1
<BLANKLINE>
...
fatal: unable to access 'http://git.erp5.org/repos/nowhere/': The requested URL returned error: 500
......
......@@ -87,12 +87,10 @@ class GitCloneNonInformativeTests(unittest.TestCase):
check_call(['git', 'config', 'user.email', 'test@example.com'], cwd=proj_dir)
check_call(['git', 'config', 'user.name', 'Test'], cwd=proj_dir)
def gitAdd(self, proj_dir, update=False):
def gitAdd(self, proj_dir):
"""runs a 'git add .' in the provided git repo
:param proj_dir: path to a git repo
:update: if True, will run 'git add -u'
"""
cmd = 'git add ' + '-u' if update else '.'
try:
check_call(['git', 'add', '.'], cwd=proj_dir)
except CalledProcessError as e:
......@@ -112,7 +110,8 @@ class GitCloneNonInformativeTests(unittest.TestCase):
Returns the sha of HEAD of a git repo
"""
try :
output = check_output(['git', 'rev-parse', 'HEAD'], cwd=proj_dir).decode("utf-8")
output = check_output(['git', 'rev-parse', 'HEAD'],
cwd=proj_dir).decode("utf-8")
return output.rstrip()
except CalledProcessError:
logging.error("failed to call 'git rev-parse'")
......@@ -228,7 +227,8 @@ class GitCloneNonInformativeTests(unittest.TestCase):
submodule_repo_path)
# Update main repo with changes of submodule
submodule_dir_main_repo = os.path.join(self.project_dir, 'dir1', 'submodule_repo')
submodule_dir_main_repo = os.path.join(self.project_dir, 'dir1',
'submodule_repo')
check_call(['git', 'checkout', 'master'], cwd=submodule_dir_main_repo)
check_call(['git', 'pull', '--ff'], cwd=submodule_dir_main_repo)
self.gitAdd(self.project_dir)
......
......@@ -172,7 +172,6 @@ class Recipe(object):
command.append(revision)
check_call(command, cwd=self.location)
def install(self):
"""
Do a git clone.
......@@ -287,15 +286,13 @@ class Recipe(object):
# but, to save time, only if we don't have the revision already
revision_already_fetched = \
self.revision and \
call([self.git_command, 'rev-parse', '--verify', self.revision],
cwd=self.location) == 0 and \
check_output([self.git_command, 'rev-parse', 'HEAD'],
cwd=self.location).strip() == self.revision
if not revision_already_fetched:
# With --recurse-submodules, it will fetch the updated branches of the
# submodules as well as of the main repo.
check_call([self.git_command, 'fetch', '--recurse-submodules', '--all'],
check_call([self.git_command, 'fetch', '--all'],
cwd=self.location)
# If develop parameter is set, don't reset/update.
......@@ -306,7 +303,7 @@ class Recipe(object):
else:
self.gitReset('@{upstream}')
if not revision_already_fetched:
if not revision_already_fetched and not self.ignore_cloning_submodules:
# Also update the submodule directory to the commit which parent
# repository is pointing to.
# NOTE: This will put the submodule repo in a `Detached` state.
......
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