def command(self, api: plug.PlatformAPI): team = api.get_teams(team_names=[self.team_name]) api.create_repo( self.repo_name, description=description, private=private, team=team, )
def _create_anonymized_repo( student_repo: plug.StudentRepo, key: str, api: plug.PlatformAPI) -> Tuple[plug.StudentRepo, plug.Repo]: anon_repo_name = _hash_if_key(student_repo.name, key=key) anon_review_team_name = _hash_if_key(student_repo.team.name, key=key) fingerprint = _anonymous_repo_fingerprint(anon_review_team_name, anon_repo_name) platform_repo = api.create_repo( name=anon_repo_name, description=f"Review copy. Fingerprint: {fingerprint}", private=True, ) _anonymize_commit_history(student_repo.path) return ( plug.StudentRepo( name=anon_repo_name, team=student_repo.team, url=student_repo.url.replace(student_repo.name, anon_repo_name), _path=student_repo.path, ), platform_repo, )
def _create_or_fetch_repo( name: str, description: str, private: bool, api: plug.PlatformAPI, team: Optional[plug.Team] = None, ) -> Tuple[bool, plug.Repo]: try: return ( True, api.create_repo( name, description=description, private=private, team=team ), ) except plug.PlatformError: team_name = team.name if team else None repo = api.get_repo(repo_name=name, team_name=team_name) if team: api.assign_repo( team=team, repo=repo, permission=plug.TeamPermission.PUSH ) return False, repo