Always delete current branch before branch creation in git
If repository must be checked out to current branch, it should be removed before recreating. Change-Id: I69a8c51ff7fca79a79a17c6c9420a4cb417061b7
This commit is contained in:
parent
1ed84bb3d3
commit
b685456913
@ -79,6 +79,14 @@ class GitDownloader(Downloader):
|
|||||||
sh.execute(*cmd, cwd=self.store_where)
|
sh.execute(*cmd, cwd=self.store_where)
|
||||||
cmd = ["git", "reset", "--hard"]
|
cmd = ["git", "reset", "--hard"]
|
||||||
sh.execute(*cmd, cwd=self.store_where)
|
sh.execute(*cmd, cwd=self.store_where)
|
||||||
|
else:
|
||||||
|
LOG.info("Downloading %s (%s) to %s.", colorizer.quote(uri), branch, colorizer.quote(self.store_where))
|
||||||
|
cmd = ["git", "clone", uri, self.store_where]
|
||||||
|
sh.execute(*cmd)
|
||||||
|
if tag:
|
||||||
|
LOG.info("Adjusting to tag %s.", colorizer.quote(tag))
|
||||||
|
else:
|
||||||
|
LOG.info("Adjusting branch to %s.", colorizer.quote(branch))
|
||||||
# detach, drop new_branch if it exists, and checkout to new_branch
|
# detach, drop new_branch if it exists, and checkout to new_branch
|
||||||
# newer git allows branch resetting: git checkout -B $new_branch
|
# newer git allows branch resetting: git checkout -B $new_branch
|
||||||
# so, all these are for compatibility with older RHEL git
|
# so, all these are for compatibility with older RHEL git
|
||||||
@ -88,14 +96,6 @@ class GitDownloader(Downloader):
|
|||||||
sh.execute(*cmd, cwd=self.store_where)
|
sh.execute(*cmd, cwd=self.store_where)
|
||||||
cmd = ["git", "branch", "-D", new_branch]
|
cmd = ["git", "branch", "-D", new_branch]
|
||||||
sh.execute(*cmd, cwd=self.store_where, ignore_exit_code=True)
|
sh.execute(*cmd, cwd=self.store_where, ignore_exit_code=True)
|
||||||
else:
|
|
||||||
LOG.info("Downloading %s (%s) to %s.", colorizer.quote(uri), branch, colorizer.quote(self.store_where))
|
|
||||||
cmd = ["git", "clone", uri, self.store_where]
|
|
||||||
sh.execute(*cmd)
|
|
||||||
if tag:
|
|
||||||
LOG.info("Adjusting to tag %s.", colorizer.quote(tag))
|
|
||||||
else:
|
|
||||||
LOG.info("Adjusting branch to %s.", colorizer.quote(branch))
|
|
||||||
cmd = ["git", "checkout"] + checkout_what
|
cmd = ["git", "checkout"] + checkout_what
|
||||||
sh.execute(*cmd, cwd=self.store_where)
|
sh.execute(*cmd, cwd=self.store_where)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user