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/reviews.py

48 lines
921 B
Python
Raw Normal View History

2019-11-22 15:03:21 +01:00
#!/usr/bin/env python3
import os
import re
import requests
from subprocess import run
import sys
2019-11-22 20:12:37 +01:00
from commands import MergeRequests, UpdateAssignees, Comments, Merge, Test
2019-11-22 15:03:21 +01:00
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(),
2019-11-22 20:12:37 +01:00
"comments": Comments(),
2019-11-22 15:03:21 +01:00
"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()