#!/usr/bin/env python3 import re from commands.base import BaseGitCommand from git import add_files, commit, push from submission import Submission from utils import run_cmd class MergeRequests(BaseGitCommand): def get_files(self, submission: Submission) -> None: files = f"{self.hw['prefix']}/" if len(self.hw['files']) > 1: files += f"{{{','.join(self.hw['files'])}}}" else: files += f"{self.hw['files'][0]}" if run_cmd("rsync", "-avzP", f"aisa:{submission.path}/{files}", "./")[0] != 0: exit(1) @staticmethod def call_flake(submission: Submission) -> None: process = run_cmd("flake8", "--exit-zero", f"{submission.homework}.py")[1] with open("flake.log", "w") as f: print(process.stdout, file=f) def exec(self, submission: Submission) -> None: self.get_files(submission) # self.call_flake(submission) add_files(*self.hw['files']) commit(f'"Add sources ({submission.branch} {submission.login})"') push("origin", submission.branch) mail = f"
\nMail\n\n
{submission.get_mail()}
" self.gitlab.post_mr( source_branch=submission.branch, target_branch="master", title=f"[{submission.homework}{'-opravne' if submission.correction else ''}] {submission.login}", description=mail, labels=submission.homework, remove_source_branch="true", assignee_ids=["1772"], )