This commit is contained in:
Patrick Lühne 2018-06-24 00:25:37 +02:00
parent 2a214ff0ba
commit 021ce2b078
Signed by: patrick
GPG Key ID: 05F3611E97A70ABF

View File

@ -57,25 +57,38 @@ class BenchmarkRepository:
remote.fetch(callbacks = callbacks)
printProgressBar("Updating the repository", 1, 1, overwrite = True)
self.forceUpdateBranch("master", self.repository)
try:
pass
#self.repository.lookup_worktree("results")
#self.repository.lookup_worktree("config")
#self.repository.lookup_worktree("status")
for branchName in ["results", "config", "status"]:
print("Updating branch {}".format(branchName))
worktree = self.repository.lookup_worktree(branchName)
worktree = pygit2.Repository(worktree.path)
self.forceUpdateBranch(branchName, worktree)
except pygit2.GitError:
raise Exception("Worktrees are not properly set up")
print(list(self.repository.branches))
else:
callbacks.transfer_progress = printCloneProgress
printProgressBar("Cloning the repository", 0, 1)
self.repository = pygit2.clone_repository(self.remote, self.branchDir("master"), callbacks = callbacks, checkout_branch = self.branches["master"])
self.repository = pygit2.Repository(self.repository.path)
printProgressBar("Cloning the repository", 1, 1, overwrite = True)
for branchName in ["results", "config", "status"]:
worktree = self.repository.add_worktree(branchName, self.branchDir(branchName))
worktree = pygit2.Repository(worktree.path)
branch = worktree.branches.local.create(branchName)
#worktree.checkout(self.branches["results"])
for branchName in ["results", "config", "status"]:
print("Preparing branch {}".format(branchName))
worktree = self.repository.add_worktree(branchName, self.branchDir(branchName))
worktree = pygit2.Repository(worktree.path)
remoteReference = worktree.lookup_reference("refs/remotes/origin/{}".format(self.branches[branchName]))
localReference = worktree.create_reference("refs/heads/{}".format(branchName), remoteReference.resolve().target)
self.forceUpdateBranch(branchName, worktree)
def branchDir(self, branchName):
return os.path.join(self.basePath, branchName)
def forceUpdateBranch(self, branchName, worktree):
worktree.checkout("refs/heads/{}".format(branchName), strategy = pygit2.GIT_CHECKOUT_FORCE | pygit2.GIT_CHECKOUT_RECREATE_MISSING)
#remoteReference = worktree.lookup_reference("refs/remotes/origin/{}".format(self.branches[branchName]))
#worktree.reset(remoteReference.target, pygit2.GIT_RESET_HARD)