promote: when the canonical copy is gone or excluded, a by-name or --toc run silently makes a stale copy canonical and reverts the pool

未关闭
#24 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
54/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
python
领域
tooling

调研方向

Start with resolve_sources in tools/promote around line 719, then inspect the promotion tests in tools/tests and the harness used by the reproduction. Add a regression test for a removed or excluded canonical source whose stale copy would change the pool, and verify promotion refuses with a warning pointing to the canonical-removed decision. Also check the normalized-identical-copy case described in the issue.

由索引模型根据 Issue 内容生成。

描述

bug

Follow-up from the review of #14. Line numbers are at #14's head as it merges.

What happens

resolve_sources judges whether a copy is stale only while the entry's recorded canonical series is eligible in the run (tools/promote:719). When the canonical copy is gone upstream, or its series is excluded from the run, nothing is judged. A by-name run (promote SLUG) or --toc of the series holding the stale copy then anchors on that copy and makes it canonical. The pool goes back to the earlier version and loses the canonical copy's later edits. The run exits 0 with an ordinary promoted line and no warning.

The refresh refuses the same entry, naming the removal, so the two modes disagree. The by-name run also hides what happened. The rewritten entry no longer records the removed series, so the drift-check goes clean, and its canonical-removed issue closes itself. That issue is the one asking for a decision about whether the lecture was retired, renamed or moved.

Reproduction (with the tools/tests harness)

repo = make_repo(["advanced", "dp-test"])
for series in ("advanced", "dp-test"):
    repo.lecture(series, "amss", lecture_text("AMSS"))
assert repo.promote("amss").returncode == 0                 # sources: advanced, dp-test
repo.lecture("advanced", "amss", lecture_text("AMSS", "A fix upstream."))
repo.move_pin("advanced")
assert repo.promote("--refresh").returncode == 0            # dp-test kept as a stale source
assert "A fix upstream." in repo.pool("amss.md").read_text()

(repo.root / "mirror" / "advanced" / "lectures" / "amss.md").unlink()
repo.move_pin("advanced", 3)                                 # advanced removes (or renames) amss.md
assert "[canonical-removed] lectures/amss.md" in repo.drift_check().stdout
assert repo.promote("--refresh").returncode == 1            # the refresh refuses, naming the removal

res = repo.promote("amss")                                   # a by-name (or --toc dp-test) run
assert res.returncode == 0 and "WARN" not in res.stdout
assert repo.entry("amss")["canonical"] == "dp-test"
assert "A fix upstream." not in repo.pool("amss.md").read_text()   # the pool lost the fix
assert repo.drift_check().returncode == 0                   # and the drift-check goes quiet

The same happens to promote amss --exclude advanced while advanced still holds its copy.

When it bites

Only on a manual run after a canonical copy has been removed or renamed upstream. CI's refresh refuses the entry, so the run has to be by name or by toc: a whole-estate promotion, the --toc dp re-homing at QuantEcon/project-monorepo#24, or an operator re-promoting a lecture. The renames in QuantEcon/project-monorepo#76 are the first realistic trigger. Main behaves the same way.

Suggested fix

When the entry's recorded canonical series no longer holds the lecture (or is excluded from the run), and the run would anchor on a recorded source still at an earlier digest, refuse the entry. The refusal should say so and point at the canonical-removed decision, unless sync/canonical.yml names that series. Take care not to refuse a source that is the same lecture only after normalisation: one test is whether promoting it would change the pool file at all. A test like the one above, inverted, covers it.

主要语言
Python
星标
1
派生
0
平均合并
2 小时 51 分钟
30 天内合并 PR
41

环境准备

这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

QuantEcon/lectures 的其他 Issue

查看 QuantEcon/lectures 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。