Beispiel #1
0
    def test_setup_with_default_branch_protection_does_not_carry_over(
            self, tmpdir):
        """Student repositories created when global default branch
        protection is enabled on the GitLab instance, should still not have
        default branch protection.
        """
        # arrange
        gl = gitlab.Gitlab(url=BASE_URL,
                           private_token=ADMIN_TOKEN,
                           ssl_verify=False)
        gl.auth()
        settings = gl.settings.get()
        settings.default_branch_protection = (
            _repobee.ext.gitlab.DefaultBranchProtection.FULL.value)
        settings.save()
        command = " ".join([
            *repobee_plug.cli.CoreCommand.repos.setup.as_name_tuple(),
            *BASE_ARGS,
            *TEMPLATE_ORG_ARG,
            *MASTER_REPOS_ARG,
            *STUDENTS_ARG,
        ])

        # act
        run_repobee(command, workdir=tmpdir, plugins=[_repobee.ext.gitlab])

        # assert
        api = api_instance(ORG_NAME)
        loop_ran = False
        for repo in api.get_repos():
            loop_ran = True
            assert not repo.implementation.protectedbranches.list()

        assert loop_ran, "assertion loop did not execute"
Beispiel #2
0
    def local_master_repos(self, restore, tmpdir):
        """Clone the master repos to disk. The restore fixture is explicitly
        included as it must be run before this fixture.
        """
        api = api_instance(TEMPLATE_ORG_NAME)
        template_repo_urls = [
            api.insert_auth(url) for url in api.get_repo_urls(assignment_names)
        ]
        # clone the master repos to disk first first
        git_commands = [
            "git clone {}".format(url) for url in template_repo_urls
        ]

        for cmd in git_commands:
            subprocess.run(shlex.split(cmd), check=True, cwd=str(tmpdir))

        return assignment_names
Beispiel #3
0
    def local_master_repos(self, restore, extra_args):
        """Clone the master repos to disk. The restore fixture is explicitly
        included as it must be run before this fixture.
        """
        api = api_instance(TEMPLATE_ORG_NAME)
        template_repo_urls = [
            api.insert_auth(url).replace(LOCAL_DOMAIN, BASE_DOMAIN)
            for url in api.get_repo_urls(assignment_names)
        ]
        # clone the master repos to disk first first
        git_commands = [
            "git clone {}".format(url) for url in template_repo_urls
        ]
        result = run_in_docker(" && ".join(git_commands),
                               extra_args=extra_args)

        assert result.returncode == 0
        return assignment_names