def load_repository(private_key): with open("./.repodata.json", "r") as repodatafile: repodata = json.load(repodatafile) global current_branch, current_commit current_branch = repodata["current_branch_id"] current_commit = repodata["current_commit_id"] repo = RepositoryContractWrapper.connect_to_repository(CONNECTION_ADDRESS, private_key, repodata["repo_address"]) return repo
def clone(repo_addr, private_key): repo = RepositoryContractWrapper.connect_to_repository(CONNECTION_ADDRESS, private_key, repo_addr) # Get the most recent commit on the branch with id 0 - mainline commit_id = repo.most_recent_commit(0) # Update the local files fetch(repo, commit_id) # Calculate the current repository data repodata = { "repo_name": repo.get_repository_name(), "repo_address": repo_addr, "current_branch_id": 0, "current_commit_id": commit_id, } # Save it to the repodata file with open("./.repodata.json", "w") as repodatafile: json.dump(repodata, repodatafile)