python / python/python-docs-zh-tw

`Makefile` should ask for confirmation before changing `../cpython`

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

@mattwang44 已经在做这个了。

开始于 2025年7月5日。

bug
主要语言
Python
星标
282
派生
226
PR 合并指标
30 天内没有已合并 PR

描述

I ran make all while already having an existing clone of cpython, and even though make detected that, it proceeded to alter it without asking for confirmation:

$ make all
...
git clone --depth 1 --no-single-branch https://github.com/python/cpython.git ../cpython/  || echo "cpython exists"
fatal: destination path '../cpython' already exists and is not an empty directory.
cpython exists
cd ../cpython/ && git checkout 3.10
Switched to branch '3.10'
Your branch is behind 'upstream/3.10' by 339 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
mkdir -p ../cpython//Doc/locales/zh_TW/LC_MESSAGES
for dirname in $(find . -name '*.po' | xargs -n1 dirname | sort -u | grep -v '^\.$'); do mkdir -p ../cpython//Doc/locales/zh_TW/LC_MESSAGES/$dirname; done
for file in *.po */*.po; do ln -f $file ../cpython//Doc/locales/zh_TW/LC_MESSAGES/$file; done
. ~/.venvs/python-docs-i18n//bin/activate; make -C ../cpython//Doc/ SPHINXOPTS='-j4 -D locale_dirs=locales -D language=zh_TW -D gettext_compact=0' autobuild-dev-html
...

Since the cpython clone already had a 3.10 branch, it switched to it and proceeded to copy files even if the branch was outdated.

It eventually failed while trying to build the docs because of a buggy.rst test file I had in the cpython repo:

checking consistency... failed

Warning, treated as error:
../cpython/Doc/buggy.rst:document isn't included in any toctree
make[2]: *** [Makefile:51: build] Error 2
make[2]: Leaving directory '../cpython/Doc'
make[1]: *** [Makefile:231: autobuild-dev-html] Error 2
make[1]: Leaving directory '../cpython/Doc'
make: *** [Makefile:54: all] Error 2

It would be better if the Makefile asked for confirmation before altering an existing clone of cpython, however it would also be useful to distinguish between an existing clone that was there before the first execution, and an existing clone that was there because make all previously created it.

The Makefile should do the following:

  • If the cpython clone doesn't exist, it could create it without asking for confirmation.
  • If it exists, it could check if Doc/locales/zh_TW/LC_MESSAGES/ already exists and if the current branch is $(BRANCH) (currently 3.10):
    • if they are, it can assume the clone was previously created by make all and continue without asking for confirmation;
    • if they aren't, it either means that the clone already existed, or that it was altered after the creation, and should ask for confirmation before switching branch and creating files;

In addition the Makefile created the venv in ~/.venvs, altering yet another "external" directory. It would be better if it created a .venv dir in the cwd instead. (I can create a separate issue for this.)

贡献指南

这个仓库没有索引到贡献指南

从这里开始

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

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

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