diff --git a/README.md b/README.md index f7024c9..140bd99 100644 --- a/README.md +++ b/README.md @@ -65,8 +65,8 @@ a key, add `--voice Aman` to narrate with a macOS voice instead. **3 graduates** finished the course with a pull request merged in a real open source project. The most recent is first. [See the wall](graduates/) ยท [Join them](lessons/15-capstone/) -@divya0795 @karthikaun +@divya0795 @thejesh23 diff --git a/graduates/README.md b/graduates/README.md index dca642b..613acf3 100644 --- a/graduates/README.md +++ b/graduates/README.md @@ -8,12 +8,12 @@ This page is generated by `tools/graduates_wall.py`. Don't edit it by hand. **3 graduates**, the most recent first. -@divya0795 @karthikaun +@divya0795 @thejesh23 | Name | GitHub | Contribution | Message | |---|---|---|---| -| Divya | [@divya0795](https://github.com/divya0795) | [psf/black#5711](https://github.com/psf/black/pull/5711) | Made Black reject --line-ranges for notebooks detected by their .ipynb extension. | | Karthik | [@karthikaun](https://github.com/karthikaun) | [thejesh23/graduation-test-project#1](https://github.com/thejesh23/graduation-test-project/pull/1) | Fixed a typo in a greeting script \(a test of the graduation flow\). | +| Divya | [@divya0795](https://github.com/divya0795) | [psf/black#5711](https://github.com/psf/black/pull/5711) | Made Black reject --line-ranges for notebooks detected by their .ipynb extension. | | Thejesh | [@thejesh23](https://github.com/thejesh23) | [python/cpython#162029](https://github.com/python/cpython/pull/162029) | My first CPython fix, in the json module. | diff --git a/tests/test_check_graduate.py b/tests/test_check_graduate.py index 28ac719..1589e3e 100644 --- a/tests/test_check_graduate.py +++ b/tests/test_check_graduate.py @@ -218,3 +218,28 @@ def test_the_wall_shows_the_newest_first_and_says_so(tmp_path, monkeypatch): assert page.index("zed.png") < page.index("anna.png"), "photos: newest first" assert page.index("[@zed]") < page.index("[@anna]"), "table: newest first" assert "The most recent is first." in wall.strip(tmp_path) + + +def test_a_graduate_added_again_counts_from_the_latest_addition(tmp_path): + """Seen with #63, #67 and #68: added, removed, added again. The newest addition is what counts.""" + + def git(*args, when=None): + import os + + env = {**os.environ, "GIT_AUTHOR_DATE": when, "GIT_COMMITTER_DATE": when} if when else None + 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") + (tmp_path / "ada.py").write_text(GOOD) + git("add", ".") + git("commit", "-qm", "add", when="2026-01-01T00:00:00") + git("rm", "-q", "ada.py") + git("commit", "-qm", "remove", when="2026-01-02T00:00:00") + (tmp_path / "ada.py").write_text(GOOD) + git("add", ".") + git("commit", "-qm", "add again", when="2026-01-03T00:00:00") + assert wall.added_time(tmp_path / "ada.py") == int(git("log", "-1", "--format=%ct")) diff --git a/tools/graduates_wall.py b/tools/graduates_wall.py index 9e21775..f2ead2e 100644 --- a/tools/graduates_wall.py +++ b/tools/graduates_wall.py @@ -63,7 +63,8 @@ def added_time(path: Path) -> int: """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. + of the merge that brought the file in, not when the learner wrote it. If + the file was removed and added again, the latest addition counts. """ try: out = subprocess.run( @@ -75,7 +76,7 @@ def added_time(path: Path) -> int: ).stdout.split() except (OSError, subprocess.SubprocessError): return 0 - return int(out[-1]) if out and out[-1].isdigit() else 0 + return int(out[0]) if out and out[0].isdigit() else 0 # git log lists the newest first def graduates(folder: Path) -> list[Graduate]: