Skip to content

Commit

Permalink
alu_repos: en los repos creados, dar role "admin" al equipo docente (#57
Browse files Browse the repository at this point in the history
)

Also:

  - actualizar PyGithub de 1.51 a 1.53 para los typing hints de
    delete_branch_on_merge (PyGithub/PyGithub#1639, incompleta)

  - eliminar ramas de except KeyError/ValueError que ya no aplican
    tras el último refactor a alu_repos.py
  • Loading branch information
dato committed Oct 2, 2020
1 parent 27e77e2 commit 42c9851
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
19 changes: 14 additions & 5 deletions algorw/corrector/alu_repos.py
Expand Up @@ -61,18 +61,19 @@ 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,
has_projects=False,
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}"
Expand All @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions algorw/corrector/corrector.py
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -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
Expand Down

0 comments on commit 42c9851

Please sign in to comment.