Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lectern/feedback_deliver.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,20 @@ def deliver(cohort, manifest, workdir, *, execute=False, close=True, merge_main=
pr_state, main_state = "-", "-"
if execute:
dest = os.path.join(workdir, gid)
gh("repo", "clone", repo, dest) # full clone: both branches present
git("-C", dest, "checkout", manifest.feedback_branch)
cl = gh("repo", "clone", repo, dest) # full clone: both branches present
co = git("-C", dest, "checkout", manifest.feedback_branch)
if getattr(cl, "returncode", 0) != 0 or getattr(co, "returncode", 0) != 0:
# repo absent / empty / no feedback branch — typically a
# non-submission that never accepted the assignment. Record and
# skip; never abort the whole cohort run on one missing repo.
entries.append({"github_id": gid, "student": r["student"],
"auto": r.get("points"), "writeup": r.get("writeup_score"),
"total": total, "grand": r.get("grand"),
"components": r.get("components"),
"student_comment": r.get("student_comment") or r.get("comment", ""),
"posted": False, "signed": False,
"pr_state": "-", "main_state": "no-repo"})
continue
fb = os.path.join(dest, "FEEDBACK.md")
existing = open(fb).read() if os.path.exists(fb) else None
if existing == md:
Expand Down
19 changes: 19 additions & 0 deletions tests/test_feedback_deliver.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,3 +204,22 @@ def test_default_gh_git_callbacks_prepend_binary(monkeypatch):
sig = inspect.signature(fd.deliver)
assert sig.parameters["gh"].default is fd._gh, "deliver default gh must wrap the gh binary"
assert sig.parameters["git"].default is fd._git, "deliver default git must wrap the git binary"


def test_execute_skips_unclonable_repo_and_continues(tmp_path):
# A non-submission repo that doesn't exist: gh clone returns non-zero (and no
# dest dir). deliver must record it as no-repo and CONTINUE to the next repo,
# not abort the whole cohort run (the crash hit live on the Lab 2 delivery).
import os as _os
_os.makedirs(tmp_path / "skyle")
def gh(*a, **k):
if a[:2] == ("repo", "clone") and str(a[2]).endswith("-bwayne"):
return _R("Could not resolve to a Repository", 1)
return _R("", 0)
gcalls = []
git = make_git(gcalls)
entries = deliver([row(), row(github_id="skyle", student="Selina Kyle")],
M, str(tmp_path), execute=True, gh=gh, git=git)
by = {e["github_id"]: e for e in entries}
assert by["bwayne"]["main_state"] == "no-repo" and by["bwayne"]["posted"] is False
assert by["skyle"]["posted"] is True # run continued; next repo delivered
Loading