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