mirror of
https://github.com/Ar9av/obsidian-wiki.git
synced 2026-09-14 20:36:34 +08:00
ea4508114e
setup.sh had an interactive git-sync flow (git init, .gitignore, remote, a generated sync.sh, optional cron) that `obsidian-wiki setup` — the entry point pip/uv installs actually run — never had, so those installs silently skipped it and .env.example documented a var nothing ever read. Move the git plumbing into obsidian_wiki/sync.py (configure_sync/run_sync/ get_remote) and expose it as `obsidian-wiki sync-setup <url>` and `obsidian-wiki sync`. `obsidian-wiki setup` now offers the same interactive prompt setup.sh always had (or accepts --remote non-interactively), and setup.sh's own prompt delegates into the same module via the CLI instead of re-implementing it. Sync status is read live from the vault's own `git remote` (via `obsidian-wiki info`) rather than a config var that could drift.
61 lines
2.3 KiB
Python
61 lines
2.3 KiB
Python
"""Regression guard for issue #153.
|
|
|
|
setup.sh (source/curl installs) used to hand-roll its own git-sync logic while
|
|
`obsidian-wiki setup` (the pip/uv CLI) had none at all — the two entrypoints
|
|
had diverged, and the one most users actually run (pip/uv) silently skipped
|
|
GitHub sync. Both now delegate to obsidian_wiki/sync.py. These tests pin that
|
|
setup.sh calls into the CLI instead of re-implementing git plumbing, and that
|
|
the CLI exposes the subcommands setup.sh (and agents, via wiki-setup) depend on.
|
|
"""
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class SetupShDelegatesToCliTest(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.setup_sh = (ROOT / "setup.sh").read_text()
|
|
|
|
def test_calls_sync_setup_subcommand(self) -> None:
|
|
self.assertIn("sync-setup", self.setup_sh)
|
|
|
|
def test_calls_cli_module_not_a_standalone_git_flow(self) -> None:
|
|
self.assertIn("obsidian_wiki.cli", self.setup_sh)
|
|
|
|
def test_does_not_hand_roll_git_init(self) -> None:
|
|
# The old setup.sh ran `git -C "$VAULT_PATH" init` directly; that logic
|
|
# must now live only in obsidian_wiki/sync.py.
|
|
self.assertNotIn('git -C "$VAULT_PATH" init', self.setup_sh)
|
|
|
|
def test_does_not_generate_a_standalone_sync_script(self) -> None:
|
|
# The old setup.sh wrote a hand-rolled ~/.obsidian-wiki/sync.sh with its
|
|
# own git add/commit/push logic — that's now `obsidian-wiki sync`.
|
|
self.assertNotIn("Wrote ~/.obsidian-wiki/sync.sh", self.setup_sh)
|
|
|
|
|
|
class EnvExampleDoesNotOverclaimTest(unittest.TestCase):
|
|
def test_no_dangling_vault_github_remote_var(self) -> None:
|
|
env_example = (ROOT / ".env.example").read_text()
|
|
self.assertNotIn("VAULT_GITHUB_REMOTE", env_example)
|
|
|
|
|
|
class CliExposesSyncSubcommandsTest(unittest.TestCase):
|
|
def setUp(self) -> None:
|
|
self.cli = (ROOT / "obsidian_wiki" / "cli.py").read_text()
|
|
|
|
def test_sync_setup_subcommand_registered(self) -> None:
|
|
self.assertIn('sub.add_parser(\n "sync-setup"', self.cli)
|
|
|
|
def test_sync_subcommand_registered(self) -> None:
|
|
self.assertIn('sub.add_parser("sync"', self.cli)
|
|
|
|
def test_setup_command_offers_sync(self) -> None:
|
|
self.assertIn("_maybe_configure_sync", self.cli)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|