chore: локальный запуск (make run, make demo-repo) + fix относительного GIT_CLONE_DIR #39
+2
-1
@@ -24,5 +24,6 @@ build/
|
|||||||
.claude/worktrees/
|
.claude/worktrees/
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
|
||||||
# local SQLite DB (bot without Docker)
|
# local run without Docker: SQLite DB, uploads clone, demo repo
|
||||||
*.db
|
*.db
|
||||||
|
data/
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
.PHONY: install lint fmt typecheck test cov up down logs ps
|
.PHONY: install lint fmt typecheck test cov up down logs ps run demo-repo
|
||||||
|
|
||||||
install:
|
install:
|
||||||
uv sync
|
uv sync
|
||||||
@@ -30,3 +30,18 @@ logs:
|
|||||||
|
|
||||||
ps:
|
ps:
|
||||||
docker compose ps
|
docker compose ps
|
||||||
|
|
||||||
|
# Run the bot on this machine without Docker: SQLite (./tgit.db) and the settings from .env
|
||||||
|
run:
|
||||||
|
uv run python -m app
|
||||||
|
|
||||||
|
# A local uploads repo seeded from the template — try the bot without SourceCraft:
|
||||||
|
# make demo-repo → put the printed GIT_UPLOADS_URL into .env → make run
|
||||||
|
DEMO_REPO := $(CURDIR)/data/demo-uploads.git
|
||||||
|
demo-repo:
|
||||||
|
@test ! -e $(DEMO_REPO) || { echo "$(DEMO_REPO) already exists"; exit 1; }
|
||||||
|
@rm -rf data/demo-seed && mkdir -p data && cp -r infra/uploads-template data/demo-seed
|
||||||
|
@cd data/demo-seed && git init -q -b main && git add -A \
|
||||||
|
&& git -c user.name=tgit-bot -c user.email=tgit-bot@users.noreply.tgit commit -qm "init: uploads template"
|
||||||
|
@git clone -q --bare data/demo-seed $(DEMO_REPO) && rm -rf data/demo-seed
|
||||||
|
@echo "GIT_UPLOADS_URL=$(DEMO_REPO)"
|
||||||
|
|||||||
+2
-1
@@ -47,7 +47,8 @@ class CommitInfo:
|
|||||||
class UploadsRepo:
|
class UploadsRepo:
|
||||||
def __init__(self, settings: GitSettings) -> None:
|
def __init__(self, settings: GitSettings) -> None:
|
||||||
self._s = settings
|
self._s = settings
|
||||||
self._dir = settings.clone_dir
|
# absolute: git clone runs from the parent dir, a relative path would land one level deeper
|
||||||
|
self._dir = settings.clone_dir.resolve()
|
||||||
self._lock = asyncio.Lock()
|
self._lock = asyncio.Lock()
|
||||||
self._fetched_at: float | None = None
|
self._fetched_at: float | None = None
|
||||||
self._key_path = self._materialize_key()
|
self._key_path = self._materialize_key()
|
||||||
|
|||||||
@@ -83,3 +83,14 @@ async def test_unreachable_remote(tmp_path: Path) -> None:
|
|||||||
broken = UploadsRepo(GitSettings(uploads_url=str(tmp_path / "missing.git"), clone_dir=tmp_path / "c3"))
|
broken = UploadsRepo(GitSettings(uploads_url=str(tmp_path / "missing.git"), clone_dir=tmp_path / "c3"))
|
||||||
with pytest.raises(GitError, match="clone"):
|
with pytest.raises(GitError, match="clone"):
|
||||||
await broken.refresh()
|
await broken.refresh()
|
||||||
|
|
||||||
|
|
||||||
|
async def test_relative_clone_dir(remote: Path, tmp_path: Path, monkeypatch: pytest.MonkeyPatch) -> None:
|
||||||
|
from app.config import GitSettings
|
||||||
|
|
||||||
|
monkeypatch.chdir(tmp_path)
|
||||||
|
relative = UploadsRepo(GitSettings(uploads_url=str(remote), clone_dir=Path("data/uploads")))
|
||||||
|
await relative.refresh()
|
||||||
|
|
||||||
|
assert (tmp_path / "data" / "uploads" / ".git").is_dir()
|
||||||
|
assert "README.md" in [e.name for e in await relative.list_dir()]
|
||||||
|
|||||||
Reference in New Issue
Block a user