Commit b1ee7390 authored by Ayush Tiwari's avatar Ayush Tiwari

Update submodules

parent 8ff4bce7
......@@ -105,25 +105,25 @@ class GitCloneNonInformativeTests(unittest.TestCase):
subprocess.check_call('git add .', cwd=proj_dir, shell=True)
except subprocess.CalledProcessError as e:
# XXX: This is ugly and old. Change it before review
logging.error("'git add .' failed with '{}'".format(e.returncode))
logging.error("'git add .' failed with '%s'" % e.returncode)
def gitCommit(self, proj_dir, msg):
"""runs a 'git commit -m msg' in the provided git repo
:param proj_dir: path to a git repo
"""
try:
subprocess.check_call('git commit -m "{}"'.format(msg),
subprocess.check_call('git commit -m "%s"' % msg,
cwd=proj_dir,
shell=True)
except subprocess.CalledProcessError as e:
logging.error("'git commit' failed with '{}'".format(e.returncode))
logging.error("'git commit' failed with '%s'" % e.returncode)
def getRepositoryHeadCommit(self, proj_dir, branch='master'):
def getRepositoryHeadCommit(self, proj_dir):
"""
Returns the sha of HEAD of a git repo
"""
try :
output = subprocess.check_output('git rev-parse {}'.format(branch),
output = subprocess.check_output('git rev-parse HEAD',
cwd=proj_dir, shell=True).decode("utf-8")
return output.rstrip()
except subprocess.CalledProcessError :
......@@ -227,6 +227,7 @@ class GitCloneNonInformativeTests(unittest.TestCase):
'revision': str(self.getRepositoryHeadCommit(self.project_dir))
}
)
#import pdb; pdb.set_trace()
recipe.update()
self.assertTrue(os.path.exists(main_repo_path))
# Check if the submodule is not empty
......
......@@ -273,6 +273,9 @@ class Recipe(object):
Do a git fetch.
If user doesn't develop, reset to remote revision (or branch if revision is
not specified).
With support for submodules, we also update the submodule repository if
there has been update to the pointer of the submodules in the parent repo.
This however puts the updated submodules in a DETACHED state.
"""
try:
# first cleanup pyc files
......@@ -289,22 +292,22 @@ class Recipe(object):
if not revision_already_fetched:
# With --recurse-submodules, it will fetch the updated branches of the
# submodules as well as of the main repo. It will remain in a detached
# head old state
# NOTE: It won't checkout to the updated master/main-branch
# submodules as well as of the main repo.
check_call([self.git_command, 'fetch', '--recurse-submodules', '--all'],
cwd=self.location)
# Also update the submodule directory
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
if not self.develop:
if self.revision:
self.gitReset(self.revision)
else:
self.gitReset('@{upstream}')
# 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.
check_call([self.git_command, 'submodule', 'update', '--recursive'],
cwd=self.location)
# If develop parameter is set, don't reset/update.
# Otherwise, reset --hard
if not self.develop:
if self.revision:
self.gitReset(self.revision)
else:
self.gitReset('@{upstream}')
except:
if not self.develop:
......
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