(repo_dir: Path, language: str)
| 1450 | else ( |
| 1451 | "GitHub 同步需要合并远端新提交,但自动 rebase 发生冲突。" |
| 1452 | f"请手动处理阅读笔记仓库冲突后再同步:{rebase_output}" |
| 1453 | ) |
| 1454 | ) from exc |
| 1455 | |
| 1456 | |
| 1457 | def _is_non_fast_forward_push(output: str) -> bool: |
| 1458 | normalized = output.lower() |
| 1459 | return "non-fast-forward" in normalized or "fetch first" in normalized |
| 1460 | |
| 1461 | |
| 1462 | def _guard_reading_notes_deletions(repo_dir: Path, language: str) -> None: |
| 1463 | deleted = [ |
| 1464 | line.strip() |
| 1465 | for line in _git_output(["diff", "--cached", "--name-only", "--diff-filter=D"], repo_dir).splitlines() |
| 1466 | if line.strip() |
| 1467 | ] |
| 1468 | if not deleted: |
| 1469 | return |
| 1470 | _run_git(["checkout", "HEAD", "--", *deleted], repo_dir, check=False) |
| 1471 | preview = "\n".join(f"- {path}" for path in deleted[:12]) |
| 1472 | if len(deleted) > 12: |
| 1473 | preview += f"\n- ... and {len(deleted) - 12} more" |
| 1474 | raise RuntimeError( |
| 1475 | ( |
| 1476 | "GitHub sync blocked because it would delete reading-note files. " |
| 1477 | "PaperFlow GUI sync is additive by default; delete files manually with Git if that is intended.\n" |
| 1478 | f"{preview}" |
| 1479 | ) |
no test coverage detected