Fix checkout when preparing a ref
The new checkout method was relying on out of date information stored in the remote which was not being updated by the fetch command. Instead, just checkout FETCH_HEAD using git directly so that the remote does not need to be kept up to date. Also, reset and clean _before_ checking out, since that's supposed to clean up from messy merges, etc. Change-Id: Ie47b675512edc36e8aeb9b537ca945ad8d07b780
This commit is contained in:
parent
5a9918ae4b
commit
6eeb24743a
|
@ -63,15 +63,13 @@ class Repo(object):
|
|||
def checkout(self, ref):
|
||||
self._ensure_cloned()
|
||||
self.log.debug("Checking out %s" % ref)
|
||||
self.log.debug(repr(ref))
|
||||
if self.repo.re_hexsha_only.match(ref):
|
||||
self.repo.head.reference = ref
|
||||
else:
|
||||
self.fetch(ref)
|
||||
self.repo.head.reference = \
|
||||
self.repo.remotes.origin.refs[ref].commit.hexsha
|
||||
self.repo.head.reset(index=True, working_tree=True)
|
||||
self.repo.git.clean('-x', '-f', '-d')
|
||||
if self.repo.re_hexsha_only.match(ref):
|
||||
self.repo.git.checkout(ref)
|
||||
else:
|
||||
self.fetch(ref)
|
||||
self.repo.git.checkout("FETCH_HEAD")
|
||||
|
||||
def cherryPick(self, ref):
|
||||
self._ensure_cloned()
|
||||
|
|
Loading…
Reference in New Issue