def test_remove_remote_branch(self, mock_labbook_lfs_disabled): lb = mock_labbook_lfs_disabled[2] with tempfile.TemporaryDirectory() as tempdir: call_subprocess('git init .'.split(), tempdir) call_subprocess('touch FILE_A'.split(), tempdir) call_subprocess('git add FILE_A'.split(), tempdir) call_subprocess('git commit -am "message"'.split(), tempdir) call_subprocess('git checkout -b remote-branch'.split(), cwd=tempdir) call_subprocess('git checkout master'.split(), cwd=tempdir) lb.git.add_remote('origin', tempdir) bm = BranchManager(lb) bm.fetch() assert 'remote-branch' in bm.branches_remote # Get this remote branch locally, but go back to master bm.workon_branch('remote-branch') call_subprocess('git checkout master'.split(), cwd=bm.repository.root_dir) bm.remove_remote_branch('remote-branch') bm.fetch() # Confirm branch exists locally, but is gone on remote. assert 'remote-branch' in bm.branches_local assert 'remote-branch' not in bm.branches_remote
def mutate_and_get_payload(cls, root, info, owner, labbook_name, branch_name, delete_local=False, delete_remote=False, client_mutation_id=None): username = get_logged_in_username() lb = InventoryManager().load_labbook(username, owner, labbook_name, author=get_logged_in_author()) with lb.lock(): bm = BranchManager(lb, username=username) if delete_local: bm.remove_branch(target_branch=branch_name) if delete_remote: bm.remove_remote_branch(target_branch=branch_name) return DeleteExperimentalBranch(Labbook(id="{}&{}".format(owner, labbook_name), name=labbook_name, owner=owner))