46 lines
883 B
Python
46 lines
883 B
Python
#!/usr/bin/env python3
|
|
|
|
import os
|
|
import re
|
|
import requests
|
|
from subprocess import run
|
|
import sys
|
|
|
|
|
|
from commands import MergeRequests, UpdateAssignees, Merge, Test
|
|
from constants import SUBMISSIONS, HOMEWORK
|
|
from git import checkout_branch
|
|
from utils import get_branch, mkcd, make_pair
|
|
|
|
|
|
def iterate_logins(func):
|
|
for login, submission in map(make_pair, SUBMISSIONS):
|
|
branch = get_branch(login)
|
|
|
|
checkout_branch(branch)
|
|
mkcd(f"{HOMEWORK}/{login}")
|
|
|
|
func(login, submission)
|
|
|
|
os.chdir("../..")
|
|
checkout_branch("master")
|
|
|
|
|
|
COMMANDS = {
|
|
"mrs": MergeRequests(),
|
|
"update-assignees": UpdateAssignees(),
|
|
"merge": Merge(),
|
|
"test": Test(),
|
|
}
|
|
|
|
|
|
def main():
|
|
if sys.argv[1] not in COMMANDS:
|
|
print("Invalid command")
|
|
exit(2)
|
|
|
|
iterate_logins(COMMANDS[sys.argv[1]])
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|