Commit 5f7fb658 authored by Ayush Tiwari's avatar Ayush Tiwari

Do not update if revision given

parent 8f904a03
......@@ -188,6 +188,7 @@ class Recipe(object):
shutil.rmtree(self.location)
else:
# If develop is set, assume that this is a valid working copy
self._update()
return [self.location]
if getattr(self, 'branch_overrided', None):
......@@ -270,6 +271,10 @@ class Recipe(object):
raise
def update(self):
if not self.revision:
self._update()
def _update(self):
"""
Do a git fetch.
If user doesn't develop, reset to remote revision (or branch if revision is
......@@ -282,41 +287,25 @@ 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 revision_exists
if not revision_already_fetched:
check_call([self.git_command, 'fetch', '--all'], 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:
check_call([self.git_command, 'fetch', '--all'], cwd=self.location)
self.gitReset('@{upstream}')
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
# repo being checked out to the desired one.
# NOTE: This will put the submodule repo in a `Detached` state.
check_call([self.git_command, 'submodule', 'update', '--recursive'],
cwd=self.location)
if not self.ignore_cloning_submodules:
# 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
# repo being checked out to the desired one.
# NOTE: This will put the submodule repo in a `Detached` state.
check_call([self.git_command, 'submodule', 'update', '--recursive'],
cwd=self.location)
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