Skip to content
Snippets Groups Projects
Commit 48a77b3b authored by Florian Bruhin's avatar Florian Bruhin
Browse files

Use autpy lib to get student branches

parent 0d9f6e0a
Branches
No related tags found
No related merge requests found
......@@ -23,29 +23,6 @@ def run(*args: str, **kwargs: Any) -> subprocess.CompletedProcess:
)
def get_student_branches() -> list[str]:
proc = run(
"for-each-ref",
"--format=%(refname:short)",
"--sort=-authordate",
"refs/remotes/origin",
)
return [
utils.removeprefix(branch, "origin/")
for branch in proc.stdout.splitlines()
if "." in branch
]
def get_student_heads() -> list[tuple[str, str]]:
proc = run(
"for-each-ref", "--format=%(refname:short) %(objectname)", "refs/remotes/origin"
)
return [line.split() for line in proc.stdout.splitlines() if "." in line]
class GitFetcher(QObject):
INTERVAL = 10 * 1000 # 10s
......
......@@ -18,6 +18,7 @@ from PyQt6.QtGui import QKeySequence, QAction
from PyQt6.QtCore import Qt, pyqtSlot, pyqtSignal, QStringListModel
from commander.gui import utils, git
from autpy import submissions
class Selector(QLineEdit):
......@@ -113,7 +114,7 @@ class BranchSelector(Selector):
self.accept_text(branch)
def _get_data(self) -> list[str]:
return git.get_student_branches()
return [info.short_name for info in submissions.get_student_branches()]
def accept_text(self, text: str) -> None:
proc = git.run("checkout", f"origin/{text}")
......
......@@ -16,6 +16,7 @@ from PyQt6.QtGui import QKeySequence, QAction
from PyQt6.QtWidgets import QLabel, QWidget, QApplication
from commander.gui import git, utils
from autpy import submissions
SHORT_SHA_LEN = 7
......@@ -170,19 +171,19 @@ class GlobalZapper(QObject):
stats.tags += len(tags)
def _collect_submissions(self, stats: CollectionStats) -> None:
for branch, commit in git.get_student_heads():
for branch_info in submissions.get_student_branches():
stats.branches += 1
info = self._submitted[branch]
info = self._submitted[branch_info.name]
if info.commit == commit:
if info.commit == branch_info.commit:
continue
info.branch = branch
info.commit = commit
info.branch = branch_info.name
info.commit = branch_info.commit
stats.changed_branches += 1
for file_info in self._collect_files(branch):
for file_info in self._collect_files(branch_info.name):
# FIXME use a queue of QProcesses instead?
QApplication.processEvents()
info.files.append(file_info)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment