Commit 8f904a03 authored by Ayush Tiwari's avatar Ayush Tiwari

Simplify checkup for already existing revision

parent 28986fbb
......@@ -282,12 +282,19 @@ class Recipe(object):
# first cleanup pyc files
self.deletePycFiles(self.location)
# Check if the revision exists in the already fetched repository
revision_exists = False
if self.revision:
try:
revision_exists = (check_output([self.git_command, 'cat-file', '-t',
self.revision]).strip() == 'commit')
except CalledProcessError:
print('Revision %s does not exits in the repository' % self.revision)
pass
# then update,
# but, to save time, only if we don't have the revision already
revision_already_fetched = \
self.revision and \
check_output([self.git_command, 'rev-parse', 'HEAD'],
cwd=self.location).strip() == self.revision
revision_already_fetched = self.revision and revision_exists
if not revision_already_fetched:
check_call([self.git_command, 'fetch', '--all'], cwd=self.location)
......@@ -300,9 +307,9 @@ class Recipe(object):
else:
self.gitReset('@{upstream}')
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.
if not self.ignore_cloning_submodules and self.revision:
# Update the submodule to the commit which parent repo points to if
# there has been revision is present for the parent repo.
# According to man-page of submodule, update also clones missing
# submodules and updating the working tree of the submodules. This is
# why we do update here only after we are ok with revision of parent
......
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