diff --git a/algorw/corrector/alu_repos.py b/algorw/corrector/alu_repos.py index 2fffc99..142d203 100644 --- a/algorw/corrector/alu_repos.py +++ b/algorw/corrector/alu_repos.py @@ -61,8 +61,8 @@ def ensure_exists(self, *, skel_repo: str = None): owner, name = self.repo_full.split("/", 1) organization = gh.get_organization(owner) - # TODO: get all settings from repos.yml - organization.create_repo( + # TODO: get all settings from repos.yml (incl. skel_repo & team_name). + new_repo = organization.create_repo( name, private=True, has_wiki=False, @@ -70,9 +70,10 @@ def ensure_exists(self, *, skel_repo: str = None): has_downloads=False, allow_squash_merge=False, allow_rebase_merge=False, + delete_branch_on_merge=False, # type: ignore ) - # TODO: poner skel_repo en la configuración. + # Hacer push de todas las ramas del esqueleto. if skel_repo is not None: skel_repo = f"git@github.com:{skel_repo}" repo_full = f"git@github.com:{self.repo_full}" @@ -82,8 +83,16 @@ def ensure_exists(self, *, skel_repo: str = None): [repo_full, "refs/remotes/origin/*:refs/heads/*"] ) - # TODO: set up team access - # TODO: configure branch protections + # Dar permiso a los docentes. + try: + team = organization.get_team_by_slug("algorw-20b") + except github.UnknownObjectException: + pass + else: + team.set_repo_permission(new_repo, "admin") + + # TODO: configure branch protections (necesario para cuando se dé permiso para + # hacer push de manera directa para las entregas, desde Git). def sync(self, entrega_dir: pathlib.Path, rama: str, *, target_subdir: str = None): """Importa una entrega a los repositorios de alumnes. diff --git a/algorw/corrector/corrector.py b/algorw/corrector/corrector.py index 48500b2..49d65a3 100755 --- a/algorw/corrector/corrector.py +++ b/algorw/corrector/corrector.py @@ -170,8 +170,6 @@ def procesar_entrega(task: CorrectorTask): alu_repo = AluRepo(task.alu_repo.full_name, task.github_id or GITHUB_USER) alu_repo.ensure_exists(skel_repo="algorw-alu/algo2_tps") alu_repo.sync(moss.location(), tp_id) - except (KeyError, ValueError): - pass except GithubException as ex: print(f"error al sincronizar: {ex}", file=sys.stderr) else: diff --git a/requirements.txt b/requirements.txt index d812bd7..d3763c2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -30,7 +30,7 @@ protobuf==3.12.4 # via google-api-core, googleapis-common-protos pyasn1-modules==0.2.8 # via google-auth, oauth2client pyasn1==0.4.8 # via oauth2client, pyasn1-modules, rsa pydantic==1.6.1 # via -r requirements.in -pygithub==1.51 # via -r requirements.in +pygithub==1.53 # via -r requirements.in pyjwt==1.7.1 # via pygithub python-dotenv==0.13.0 # via -r requirements.in pytz==2020.1 # via google-api-core