This repository has been archived on 2023-07-17. You can view files and clone it, but cannot push or open issues or pull requests.
pushee/commands/merge_requests.py

45 lines
1.4 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
import re
from commands.base import BaseGitCommand
from git import add_files, commit, push
from gitlab import post_mr
2019-11-30 17:47:52 +01:00
from submission import Submission
from utils import run_cmd
class MergeRequests(BaseGitCommand):
@staticmethod
2019-11-30 17:47:52 +01:00
def get_files(submission: Submission) -> None:
2019-11-30 22:47:08 +01:00
files = f"master-naostro/LoadTest/{submission.homework}.py"
2019-11-30 17:47:52 +01:00
if run_cmd("rsync", "-avzP", f"aisa:{submission.path}/{files}", "./")[0] != 0:
exit(1)
@staticmethod
2019-11-30 17:47:52 +01:00
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)
2019-11-30 17:47:52 +01:00
def exec(self, submission: Submission) -> None:
self.get_files(submission)
2019-11-30 17:47:52 +01:00
self.call_flake(submission)
2019-11-30 17:47:52 +01:00
add_files(f"{submission.homework}.py", "flake.log")
commit(f'"Add sources and flake log ({submission.branch} {submission.login})"')
push("origin", submission.branch)
post_mr(
2019-11-30 17:47:52 +01:00
source_branch=submission.branch,
target_branch="master",
2019-12-02 11:39:23 +01:00
title=f"[{submission.homework}{'-opravne' if submission.correction else ''}] {submission.login}",
2019-11-30 22:47:08 +01:00
description=f"```\n{submission.get_mail()}\n```",
2019-11-30 17:47:52 +01:00
labels=submission.homework,
remove_source_branch="true",
assignee_ids=["1772"],
)