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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ a key, add `--voice Aman` to narrate with a macOS voice instead.
<!-- graduates:start -->
**3 graduates** finished the course with a pull request merged in a real open source project. [See the wall](graduates/) · [Join them](lessons/15-capstone/)

<a href="https://github.com/karthikaun"><img src="https://github.com/karthikaun.png?size=96" width="48" height="48" alt="@karthikaun" title="Karthik"></a>
<a href="https://github.com/divya0795"><img src="https://github.com/divya0795.png?size=96" width="48" height="48" alt="@divya0795" title="Divya"></a>
<a href="https://github.com/karthikaun"><img src="https://github.com/karthikaun.png?size=96" width="48" height="48" alt="@karthikaun" title="Karthik"></a>
<a href="https://github.com/thejesh23"><img src="https://github.com/thejesh23.png?size=96" width="48" height="48" alt="@thejesh23" title="Thejesh"></a>
<!-- graduates:end -->

Expand Down
31 changes: 31 additions & 0 deletions tests/test_check_graduate.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,34 @@ def test_the_repo_front_page_has_the_markers():
text = (wall.ROOT / "README.md").read_text(encoding="utf-8")
assert text.count(wall.START) == 1 and text.count(wall.END) == 1
assert text.index(wall.START) < text.index(wall.END)


def test_newest_means_merged_last_not_written_last(tmp_path, monkeypatch):
"""A learner can write their file days before it's merged; the strip orders by the merge."""

def git(*args, when=None):
env = None
if when:
import os

env = {**os.environ, "GIT_AUTHOR_DATE": when, "GIT_COMMITTER_DATE": when}
return subprocess.run(
["git", *args], cwd=tmp_path, check=True, capture_output=True, text=True, env=env
).stdout.strip()

git("init", "-q", "-b", "main")
git("config", "user.email", "t@example.com")
git("config", "user.name", "t")
git("commit", "-q", "--allow-empty", "-m", "base", when="2026-01-01T00:00:00")
for login, written, merged in (("early", "2026-01-02T00:00:00", "2026-01-10T00:00:00"),
("late", "2026-01-05T00:00:00", "2026-01-06T00:00:00")): # fmt: skip
git("switch", "-q", "-c", login, "main")
(tmp_path / f"{login}.py").write_text(GOOD.replace('"ada"', f'"{login}"'))
git("add", ".")
git("commit", "-qm", login, when=written)
git("switch", "-q", "main")
git("merge", "-q", "--no-ff", login, "-m", f"merge {login}", when=merged)

assert wall.added_time(tmp_path / "early.py") > wall.added_time(tmp_path / "late.py")
block = wall.strip(tmp_path)
assert block.index("early.png") < block.index("late.png"), "merged last, shown first"
10 changes: 7 additions & 3 deletions tools/graduates_wall.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,14 +56,18 @@ class Graduate:
repo: str
number: str
message: str
added: int = 0 # when the file was first committed (seconds), 0 if unknown
added: int = 0 # when the file landed on this branch (seconds), 0 if unknown


def added_time(path: Path) -> int:
"""When the graduate's file was first committed, so the newest can be shown first."""
"""When the graduate's file landed on this branch, so the newest graduates come first.

``--first-parent`` follows the branch's own history, so this is the time
of the merge that brought the file in, not when the learner wrote it.
"""
try:
out = subprocess.run(
["git", "log", "--diff-filter=A", "--format=%ct", "--", path.name],
["git", "log", "--first-parent", "--diff-filter=A", "--format=%ct", "--", path.name],
cwd=path.parent,
capture_output=True,
text=True,
Expand Down
Loading