offgit 0.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- offgit/__init__.py +4 -0
- offgit/cli.py +498 -0
- offgit/client.py +1636 -0
- offgit/config.py +281 -0
- offgit/errors.py +115 -0
- offgit/gitrepo.py +186 -0
- offgit/hashing.py +22 -0
- offgit/identity.py +243 -0
- offgit/local_state.py +255 -0
- offgit/output.py +160 -0
- offgit/paths.py +367 -0
- offgit/protocol.py +466 -0
- offgit/reconcile.py +169 -0
- offgit/server/__init__.py +1 -0
- offgit/server/backup.py +401 -0
- offgit/server/cli.py +391 -0
- offgit/server/export.py +75 -0
- offgit/server/health.py +59 -0
- offgit/server/locks.py +48 -0
- offgit/server/migrate.py +59 -0
- offgit/server/migrations/__init__.py +12 -0
- offgit/server/migrations/v001_initial.py +57 -0
- offgit/server/restore.py +207 -0
- offgit/server/rpc.py +187 -0
- offgit/server/schema.py +228 -0
- offgit/server/settings.py +140 -0
- offgit/server/store.py +658 -0
- offgit/transport.py +304 -0
- offgit-0.1.0.dist-info/METADATA +171 -0
- offgit-0.1.0.dist-info/RECORD +33 -0
- offgit-0.1.0.dist-info/WHEEL +4 -0
- offgit-0.1.0.dist-info/entry_points.txt +3 -0
- offgit-0.1.0.dist-info/licenses/LICENSE +21 -0
offgit/transport.py
ADDED
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
"""Client transports and the RPC call wrapper.
|
|
2
|
+
|
|
3
|
+
``SSHTransport`` runs ``ssh`` with an argv list (never a shell), strict host-key
|
|
4
|
+
checking, BatchMode, no TTY and no forwarding, and a *fixed* remote command.
|
|
5
|
+
Stdout/stderr are read concurrently with hard byte caps and an overall timeout.
|
|
6
|
+
|
|
7
|
+
``LocalTransport`` runs the real RPC handler in-process with the same framing;
|
|
8
|
+
it exists for tests and is never selected by configuration.
|
|
9
|
+
"""
|
|
10
|
+
|
|
11
|
+
from __future__ import annotations
|
|
12
|
+
|
|
13
|
+
import os
|
|
14
|
+
import shutil
|
|
15
|
+
import subprocess
|
|
16
|
+
import threading
|
|
17
|
+
import time
|
|
18
|
+
import uuid
|
|
19
|
+
from collections.abc import Callable
|
|
20
|
+
from typing import Any, Protocol
|
|
21
|
+
|
|
22
|
+
from offgit import __version__
|
|
23
|
+
from offgit.config import ServerConfig
|
|
24
|
+
from offgit.errors import (
|
|
25
|
+
EXIT_CONFLICT,
|
|
26
|
+
EXIT_CONNECTIVITY,
|
|
27
|
+
EXIT_PARTIAL,
|
|
28
|
+
EXIT_USAGE,
|
|
29
|
+
ConfigError,
|
|
30
|
+
ConnectivityError,
|
|
31
|
+
OffgitError,
|
|
32
|
+
ProtocolError,
|
|
33
|
+
)
|
|
34
|
+
from offgit.protocol import (
|
|
35
|
+
MAX_MESSAGE_BYTES,
|
|
36
|
+
MAX_STDERR_BYTES,
|
|
37
|
+
PROTOCOL_VERSION,
|
|
38
|
+
dumps,
|
|
39
|
+
loads_strict,
|
|
40
|
+
validate_response_envelope,
|
|
41
|
+
)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class TransportError(ConnectivityError):
|
|
45
|
+
"""The request may or may not have reached the server (``maybe_sent``)."""
|
|
46
|
+
|
|
47
|
+
default_code = "transport_error"
|
|
48
|
+
|
|
49
|
+
def __init__(self, message: str, *, maybe_sent: bool, **kw: Any) -> None:
|
|
50
|
+
super().__init__(message, **kw)
|
|
51
|
+
self.maybe_sent = maybe_sent
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
_REMOTE_EXIT = {
|
|
55
|
+
"project_not_found": EXIT_USAGE,
|
|
56
|
+
"project_exists": EXIT_USAGE,
|
|
57
|
+
"not_registered": EXIT_USAGE,
|
|
58
|
+
"already_registered": EXIT_USAGE,
|
|
59
|
+
"invalid_path": EXIT_USAGE,
|
|
60
|
+
"path_collision": EXIT_USAGE,
|
|
61
|
+
"limit_exceeded": EXIT_USAGE,
|
|
62
|
+
"not_found": EXIT_USAGE,
|
|
63
|
+
"revision_not_found": EXIT_USAGE,
|
|
64
|
+
"revision_conflict": EXIT_CONFLICT,
|
|
65
|
+
"revision_changed": EXIT_CONFLICT,
|
|
66
|
+
"path_conflict": EXIT_CONFLICT,
|
|
67
|
+
"epoch_mismatch": EXIT_PARTIAL,
|
|
68
|
+
"request_id_reused": EXIT_PARTIAL,
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
class RemoteError(OffgitError):
|
|
73
|
+
"""Structured error returned by the server; the request definitely did not commit."""
|
|
74
|
+
|
|
75
|
+
def __init__(self, code: str, message: str, details: dict[str, Any] | None = None) -> None:
|
|
76
|
+
super().__init__(f"server: {message}", code=code, details=details or {})
|
|
77
|
+
self.exit_code = _REMOTE_EXIT.get(code, EXIT_CONNECTIVITY)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
class Transport(Protocol):
|
|
81
|
+
def call(self, payload: bytes, *, timeout: float) -> bytes: ...
|
|
82
|
+
|
|
83
|
+
def describe(self) -> str: ...
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
def ssh_executable() -> str:
|
|
87
|
+
override = os.environ.get("OFFGIT_SSH")
|
|
88
|
+
if override:
|
|
89
|
+
return override
|
|
90
|
+
exe = shutil.which("ssh")
|
|
91
|
+
if not exe:
|
|
92
|
+
raise ConfigError("OpenSSH client 'ssh' not found on PATH", code="ssh_missing")
|
|
93
|
+
return exe
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
class SSHTransport:
|
|
97
|
+
def __init__(self, cfg: ServerConfig) -> None:
|
|
98
|
+
cfg.validate()
|
|
99
|
+
self.cfg = cfg
|
|
100
|
+
|
|
101
|
+
def describe(self) -> str:
|
|
102
|
+
return f"{self.cfg.host} (SSH)"
|
|
103
|
+
|
|
104
|
+
def argv(self) -> list[str]:
|
|
105
|
+
c = self.cfg
|
|
106
|
+
argv = [
|
|
107
|
+
ssh_executable(),
|
|
108
|
+
"-T",
|
|
109
|
+
"-o", "BatchMode=yes",
|
|
110
|
+
"-o", "StrictHostKeyChecking=yes",
|
|
111
|
+
"-o", f"ConnectTimeout={int(c.connect_timeout)}",
|
|
112
|
+
"-o", "ServerAliveInterval=15",
|
|
113
|
+
"-o", "ServerAliveCountMax=3",
|
|
114
|
+
"-o", "ForwardAgent=no",
|
|
115
|
+
"-o", "ForwardX11=no",
|
|
116
|
+
"-o", "ClearAllForwardings=yes",
|
|
117
|
+
"-o", "RequestTTY=no",
|
|
118
|
+
"-o", "LogLevel=ERROR",
|
|
119
|
+
] # fmt: skip
|
|
120
|
+
if c.port is not None:
|
|
121
|
+
argv += ["-p", str(int(c.port))]
|
|
122
|
+
if c.identity_file is not None:
|
|
123
|
+
argv += ["-i", os.path.expanduser(c.identity_file), "-o", "IdentitiesOnly=yes"]
|
|
124
|
+
if c.user is not None:
|
|
125
|
+
argv += ["-l", c.user]
|
|
126
|
+
argv += ["--", c.host, c.remote_command]
|
|
127
|
+
return argv
|
|
128
|
+
|
|
129
|
+
def call(self, payload: bytes, *, timeout: float) -> bytes:
|
|
130
|
+
return run_bounded(self.argv(), payload, timeout=timeout, what=self.describe())
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
def run_bounded(argv: list[str], payload: bytes, *, timeout: float, what: str) -> bytes:
|
|
134
|
+
try:
|
|
135
|
+
proc = subprocess.Popen(
|
|
136
|
+
argv,
|
|
137
|
+
stdin=subprocess.PIPE,
|
|
138
|
+
stdout=subprocess.PIPE,
|
|
139
|
+
stderr=subprocess.PIPE,
|
|
140
|
+
start_new_session=True,
|
|
141
|
+
)
|
|
142
|
+
except OSError as exc:
|
|
143
|
+
raise TransportError(
|
|
144
|
+
f"cannot start ssh: {exc.strerror}", maybe_sent=False, code="ssh_failed"
|
|
145
|
+
) from exc
|
|
146
|
+
|
|
147
|
+
out: list[bytes] = []
|
|
148
|
+
err: list[bytes] = []
|
|
149
|
+
overflow: list[str] = []
|
|
150
|
+
|
|
151
|
+
def reader(stream: Any, sink: list[bytes], cap: int, label: str) -> None:
|
|
152
|
+
total = 0
|
|
153
|
+
while True:
|
|
154
|
+
chunk = stream.read(65536)
|
|
155
|
+
if not chunk:
|
|
156
|
+
break
|
|
157
|
+
total += len(chunk)
|
|
158
|
+
if total > cap:
|
|
159
|
+
overflow.append(label)
|
|
160
|
+
proc.kill()
|
|
161
|
+
break
|
|
162
|
+
sink.append(chunk)
|
|
163
|
+
|
|
164
|
+
def writer() -> None:
|
|
165
|
+
try:
|
|
166
|
+
assert proc.stdin is not None
|
|
167
|
+
proc.stdin.write(payload)
|
|
168
|
+
except (BrokenPipeError, OSError):
|
|
169
|
+
pass
|
|
170
|
+
finally:
|
|
171
|
+
try:
|
|
172
|
+
assert proc.stdin is not None
|
|
173
|
+
proc.stdin.close()
|
|
174
|
+
except OSError:
|
|
175
|
+
pass
|
|
176
|
+
|
|
177
|
+
threads = [
|
|
178
|
+
threading.Thread(target=writer, daemon=True),
|
|
179
|
+
threading.Thread(
|
|
180
|
+
target=reader, args=(proc.stdout, out, MAX_MESSAGE_BYTES + 1, "stdout"), daemon=True
|
|
181
|
+
),
|
|
182
|
+
threading.Thread(
|
|
183
|
+
target=reader, args=(proc.stderr, err, MAX_STDERR_BYTES, "stderr"), daemon=True
|
|
184
|
+
),
|
|
185
|
+
]
|
|
186
|
+
for t in threads:
|
|
187
|
+
t.start()
|
|
188
|
+
deadline = time.monotonic() + timeout
|
|
189
|
+
try:
|
|
190
|
+
proc.wait(timeout=timeout)
|
|
191
|
+
except subprocess.TimeoutExpired:
|
|
192
|
+
proc.kill()
|
|
193
|
+
proc.wait()
|
|
194
|
+
for t in threads:
|
|
195
|
+
t.join(timeout=2)
|
|
196
|
+
raise TransportError(
|
|
197
|
+
f"timed out after {timeout:.0f}s talking to {what}",
|
|
198
|
+
maybe_sent=True,
|
|
199
|
+
code="timeout",
|
|
200
|
+
) from None
|
|
201
|
+
for t in threads:
|
|
202
|
+
t.join(timeout=max(0.1, deadline - time.monotonic()))
|
|
203
|
+
if overflow:
|
|
204
|
+
raise TransportError(
|
|
205
|
+
f"{what} produced more {overflow[0]} than allowed",
|
|
206
|
+
maybe_sent=True,
|
|
207
|
+
code="protocol_error",
|
|
208
|
+
)
|
|
209
|
+
stderr_text = b"".join(err).decode("utf-8", "replace").strip()
|
|
210
|
+
stdout = b"".join(out)
|
|
211
|
+
if proc.returncode != 0 and not stdout:
|
|
212
|
+
first = stderr_text.splitlines()[-1] if stderr_text else ""
|
|
213
|
+
hint = None
|
|
214
|
+
if proc.returncode == 255:
|
|
215
|
+
hint = (
|
|
216
|
+
"Check that the server is online and reachable (Tailscale), that its host key is "
|
|
217
|
+
"in known_hosts, and that your SSH key is authorized. Run 'offgit doctor'."
|
|
218
|
+
)
|
|
219
|
+
raise TransportError(
|
|
220
|
+
f"ssh to {what} failed (exit {proc.returncode}){': ' + first[:300] if first else ''}",
|
|
221
|
+
maybe_sent=proc.returncode != 255,
|
|
222
|
+
code="ssh_failed",
|
|
223
|
+
hint=hint,
|
|
224
|
+
)
|
|
225
|
+
return stdout
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
class LocalTransport:
|
|
229
|
+
"""In-process transport running the real server handler (tests only)."""
|
|
230
|
+
|
|
231
|
+
def __init__(
|
|
232
|
+
self,
|
|
233
|
+
settings: Any,
|
|
234
|
+
*,
|
|
235
|
+
store_factory: Callable[[Any], Any] | None = None,
|
|
236
|
+
before_send: Callable[[dict[str, Any]], None] | None = None,
|
|
237
|
+
after_response: Callable[[dict[str, Any], bytes], bytes] | None = None,
|
|
238
|
+
) -> None:
|
|
239
|
+
self.settings = settings
|
|
240
|
+
self.store_factory = store_factory
|
|
241
|
+
self.before_send = before_send
|
|
242
|
+
self.after_response = after_response
|
|
243
|
+
self.calls: list[dict[str, Any]] = []
|
|
244
|
+
|
|
245
|
+
def describe(self) -> str:
|
|
246
|
+
return "local (in-process)"
|
|
247
|
+
|
|
248
|
+
def call(self, payload: bytes, *, timeout: float) -> bytes:
|
|
249
|
+
from offgit.server.rpc import handle_request_bytes
|
|
250
|
+
|
|
251
|
+
doc = loads_strict(payload)
|
|
252
|
+
self.calls.append(doc)
|
|
253
|
+
if self.before_send:
|
|
254
|
+
self.before_send(doc)
|
|
255
|
+
resp = handle_request_bytes(payload, self.settings, store_factory=self.store_factory)
|
|
256
|
+
if self.after_response:
|
|
257
|
+
resp = self.after_response(doc, resp)
|
|
258
|
+
return resp
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
class RpcClient:
|
|
262
|
+
def __init__(self, transport: Transport, *, device: str, timeout: float = 120.0) -> None:
|
|
263
|
+
self.transport = transport
|
|
264
|
+
self.device = device
|
|
265
|
+
self.timeout = timeout
|
|
266
|
+
self.last_server: dict[str, Any] | None = None
|
|
267
|
+
self.bytes_sent = 0
|
|
268
|
+
self.bytes_received = 0
|
|
269
|
+
|
|
270
|
+
def build(self, operation: str, request_id: str | None = None, **fields: Any) -> dict[str, Any]:
|
|
271
|
+
return {
|
|
272
|
+
"version": PROTOCOL_VERSION,
|
|
273
|
+
"request_id": request_id or str(uuid.uuid4()),
|
|
274
|
+
"operation": operation,
|
|
275
|
+
"device": self.device,
|
|
276
|
+
"client_version": __version__,
|
|
277
|
+
**fields,
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
def send(self, request: dict[str, Any]) -> dict[str, Any]:
|
|
281
|
+
payload = dumps(request)
|
|
282
|
+
if len(payload) > MAX_MESSAGE_BYTES:
|
|
283
|
+
raise ProtocolError("request exceeds the 64 MiB message cap", code="message_too_large")
|
|
284
|
+
self.bytes_sent += len(payload)
|
|
285
|
+
raw = self.transport.call(payload, timeout=self.timeout)
|
|
286
|
+
self.bytes_received += len(raw)
|
|
287
|
+
try:
|
|
288
|
+
doc = loads_strict(raw)
|
|
289
|
+
validate_response_envelope(doc, request["request_id"])
|
|
290
|
+
except ProtocolError as exc:
|
|
291
|
+
raise TransportError(
|
|
292
|
+
f"invalid response from server: {exc.message}",
|
|
293
|
+
maybe_sent=True,
|
|
294
|
+
code="protocol_error",
|
|
295
|
+
) from exc
|
|
296
|
+
if doc["server"] is not None:
|
|
297
|
+
self.last_server = doc["server"]
|
|
298
|
+
if not doc["ok"]:
|
|
299
|
+
err = doc["error"]
|
|
300
|
+
raise RemoteError(err["code"], str(err.get("message", "")), err.get("details") or {})
|
|
301
|
+
return doc["result"]
|
|
302
|
+
|
|
303
|
+
def call(self, operation: str, **fields: Any) -> dict[str, Any]:
|
|
304
|
+
return self.send(self.build(operation, **fields))
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: offgit
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Versioned synchronization for files Git ignores.
|
|
5
|
+
Project-URL: Documentation, https://github.com/sjcsoftware/offgit/tree/main/docs
|
|
6
|
+
Project-URL: Repository, https://github.com/sjcsoftware/offgit
|
|
7
|
+
Author: offgit contributors
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: backup,git,gitignore,ssh,sync
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Environment :: Console
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: MacOS
|
|
15
|
+
Classifier: Operating System :: POSIX :: Linux
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
20
|
+
Classifier: Topic :: Software Development :: Version Control :: Git
|
|
21
|
+
Requires-Python: >=3.11
|
|
22
|
+
Requires-Dist: rich>=13.7
|
|
23
|
+
Requires-Dist: typer>=0.12
|
|
24
|
+
Description-Content-Type: text/markdown
|
|
25
|
+
|
|
26
|
+
<div align="center">
|
|
27
|
+
|
|
28
|
+
# offgit
|
|
29
|
+
|
|
30
|
+
[](https://github.com/sjcsoftware/offgit/actions/workflows/ci.yml)
|
|
31
|
+
[](https://github.com/sjcsoftware/offgit/releases)
|
|
32
|
+
[](LICENSE)
|
|
33
|
+
[](pyproject.toml)
|
|
34
|
+
|
|
35
|
+
[](docs/server-setup.md)
|
|
36
|
+
[](#install)
|
|
37
|
+
|
|
38
|
+
### Versioned sync for files Git ignores.
|
|
39
|
+
|
|
40
|
+
`.env`, `PLAN.md`, `TODO.md` kept in sync across your machines.
|
|
41
|
+
|
|
42
|
+
[Install](#install) · [Quick Start](#quick-start) · [How it works](#how-it-works) · [Docs](#docs)
|
|
43
|
+
|
|
44
|
+
</div>
|
|
45
|
+
|
|
46
|
+
---
|
|
47
|
+
|
|
48
|
+
```sh
|
|
49
|
+
offgit init -f .env PLAN.md # once, at the project root
|
|
50
|
+
offgit push # to your Pi, NAS, etc.
|
|
51
|
+
|
|
52
|
+
# --Another machine--
|
|
53
|
+
offgit pull # Detects `git remote -v` and auto-pulls relevant files
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
> [!IMPORTANT]
|
|
57
|
+
> **Your own server is the source of truth.** offgit talks only to a machine you own (e.g. a
|
|
58
|
+
> Raspberry Pi on Tailscale) over SSH. There's no cloud fallback and no silent overwrite: if both
|
|
59
|
+
> sides changed a file, nothing is touched until you choose.
|
|
60
|
+
|
|
61
|
+
## Install
|
|
62
|
+
|
|
63
|
+
| Side | Install | Platform | Requires |
|
|
64
|
+
|---|---|---|---|
|
|
65
|
+
| **Client** | `offgit` | macOS or Linux | Python ≥ 3.11, Git, OpenSSH |
|
|
66
|
+
| **Server** | `offgit-server` | Linux (Ubuntu 24.04, arm64 / x86-64) | Python ≥ 3.11, OpenSSH server |
|
|
67
|
+
|
|
68
|
+
**Client**
|
|
69
|
+
|
|
70
|
+
```sh
|
|
71
|
+
uv tool install offgit # or: pipx install offgit
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
**Server**
|
|
75
|
+
|
|
76
|
+
```sh
|
|
77
|
+
curl -fsSL https://raw.githubusercontent.com/sjcsoftware/offgit/main/deploy/install-server.sh | sudo bash
|
|
78
|
+
# add -s -- --with-backup-tools for restic + rclone, -s -- --dry-run to preview
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
This creates a no-sudo `offgit` user, `/opt/offgit/venv`, and `/var/lib/offgit`. It never
|
|
82
|
+
touches your firewall, Tailscale, or `sshd_config`. [Server setup](docs/server-setup.md)
|
|
83
|
+
|
|
84
|
+
## Quick Start
|
|
85
|
+
|
|
86
|
+
> Server (once per client device)
|
|
87
|
+
```sh
|
|
88
|
+
# authorize the device's dedicated key, locked to the RPC command
|
|
89
|
+
echo 'restrict,command="/opt/offgit/venv/bin/offgit-server rpc" ssh-ed25519 AAAA... laptop' \
|
|
90
|
+
| sudo tee -a /var/lib/offgit/.ssh/authorized_keys
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
> Client
|
|
94
|
+
```sh
|
|
95
|
+
# 1) Connect Once (the host key must already be in known_hosts)
|
|
96
|
+
offgit configure --host pi5 --user offgit --identity ~/.ssh/offgit_ed25519
|
|
97
|
+
offgit doctor
|
|
98
|
+
|
|
99
|
+
# 2) First machine: register ignored files
|
|
100
|
+
cd ~/projects/myapp
|
|
101
|
+
offgit init -f .env PLAN.md TASKS.md
|
|
102
|
+
|
|
103
|
+
# 3) Other machines: automatically identifies repo with git remote address
|
|
104
|
+
cd ~/Developer/myapp
|
|
105
|
+
git pull
|
|
106
|
+
offgit pull
|
|
107
|
+
|
|
108
|
+
# 4) Day to day
|
|
109
|
+
offgit status
|
|
110
|
+
offgit push
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Commands
|
|
114
|
+
|
|
115
|
+
| Command | Does |
|
|
116
|
+
|---|---|
|
|
117
|
+
| `push` / `pull` / `sync` | Upload local changes / download server changes / both. `--dry-run` changes nothing. |
|
|
118
|
+
| `status` / `diff` / `list` | Per-file state, unified diff server → local, and registered files. Read-only. |
|
|
119
|
+
| `add` / `remove` | Register more files, or unregister for all devices (local files kept). |
|
|
120
|
+
| `history` / `restore FILE -r N` | Revision log, and republish an old version as a new revision. |
|
|
121
|
+
| `push --prefer-local F` / `pull --prefer-remote F` | Resolve a conflict explicitly; the other side's copy is kept. |
|
|
122
|
+
| `rebaseline` | Re-verify after the server was restored from backup. |
|
|
123
|
+
|
|
124
|
+
Every command takes `--json`. Exit codes: `0` ok · `2` usage · `3` server unreachable · `4` conflict · `5` partial or recovery needed.
|
|
125
|
+
|
|
126
|
+
## How it works
|
|
127
|
+
|
|
128
|
+
| Piece | What happens |
|
|
129
|
+
|---|---|
|
|
130
|
+
| **Identity** | `https://github.com/o/r`, `git@github.com:o/r.git` and `ssh://…` all map to `github.com/o/r`. Credentials are stripped. |
|
|
131
|
+
| **Selection** | Exact paths only, each one untracked *and* ignored according to Git itself. Checked again before every read and write. |
|
|
132
|
+
| **Sync** | Three-way compare per file (last common base, local, server) by SHA-256. No mtimes, no newline changes, binary-safe. |
|
|
133
|
+
| **Server** | One SQLite file. Every change is one transaction with compare-and-swap, and full history is kept. |
|
|
134
|
+
| **Transport** | One JSON request per `ssh` call to a forced command. No daemon, no open port. |
|
|
135
|
+
| **Local state** | Lives in `.git/offgit/`, so `git status` stays clean. |
|
|
136
|
+
|
|
137
|
+
## Backups
|
|
138
|
+
|
|
139
|
+
The server makes hourly, encrypted, versioned backups to Google Drive with restic + rclone.
|
|
140
|
+
Clients never talk to the cloud. [Backup & restore →](docs/backup-and-recovery.md)
|
|
141
|
+
|
|
142
|
+
> [!WARNING]
|
|
143
|
+
> **Limitations**
|
|
144
|
+
> - One owner, several devices. Every authorized key can access every project.
|
|
145
|
+
> - Small files: 8 MiB per file, 32 MiB and 256 paths per project by default.
|
|
146
|
+
> - All branches and worktrees of a remote share one set of files.
|
|
147
|
+
> - Repository renames aren't followed automatically.
|
|
148
|
+
>
|
|
149
|
+
> [Security & residual risks](docs/security.md)
|
|
150
|
+
|
|
151
|
+
## Docs
|
|
152
|
+
|
|
153
|
+
- [Server setup](docs/server-setup.md): install, keys, Tailscale, upgrades
|
|
154
|
+
- [Backup & recovery](docs/backup-and-recovery.md): rclone, restic, retention, restore drill
|
|
155
|
+
- [Architecture](docs/architecture.md) · [Protocol](docs/protocol.md) · [Security](docs/security.md) · [Decisions](docs/decisions.md) · [Test report](docs/testing.md)
|
|
156
|
+
|
|
157
|
+
## Development
|
|
158
|
+
|
|
159
|
+
```sh
|
|
160
|
+
uv sync --all-groups
|
|
161
|
+
uv run ruff check . && uv run mypy && uv run pytest
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
## Uninstall
|
|
165
|
+
|
|
166
|
+
```sh
|
|
167
|
+
uv tool uninstall offgit # client: your files stay where they are
|
|
168
|
+
sudo rm -rf /opt/offgit # server app: data in /var/lib/offgit is kept
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
MIT License
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
offgit/__init__.py,sha256=ew-Snem9wygEuEZr-gfOl16Svbpgc9OYFaCBqqWWEcU,107
|
|
2
|
+
offgit/cli.py,sha256=Q45HnucO--Pqjt953KUAjmtBwmkH5tEQZ_LLifz36Dw,15780
|
|
3
|
+
offgit/client.py,sha256=oFhOT6rX10uCkHphjtKqSm6RHcIL24-qxS3AAxKdZgk,64034
|
|
4
|
+
offgit/config.py,sha256=F_jHSFIPuMgZfQME1NDodl9h3BAZxBbfbeW_nC41utk,9938
|
|
5
|
+
offgit/errors.py,sha256=sW3bd5Xrp-URsQYgLO3bWWvcEVJ8Ayc9g3woaTseml0,2820
|
|
6
|
+
offgit/gitrepo.py,sha256=crnxIEgXAEIVAHO8cIHXlr1QzinqLBoecPGaBWhQ48A,6824
|
|
7
|
+
offgit/hashing.py,sha256=YRxjlDuWvTXQY8MD-EnHYuMxubTY8jzkgRohEI_Veeo,514
|
|
8
|
+
offgit/identity.py,sha256=TUzFiXnHwoF4XGKHRgo3gVxqKALswo1BHuBUhhSXjrE,10279
|
|
9
|
+
offgit/local_state.py,sha256=HiieQt3qHvUnBb34iLNXXcQZnexE3zRWIbfcNUpPn1U,9268
|
|
10
|
+
offgit/output.py,sha256=QbnFixYFRBWWT4v7RbTBRXXvr6oKrOIV5FA59WTJDVM,5687
|
|
11
|
+
offgit/paths.py,sha256=XwoEWNb4yQzvvbztmmOemnzRw1PNnGdPgpHr5KiUy24,14381
|
|
12
|
+
offgit/protocol.py,sha256=wQP3V_64FeHDTirTudzsAhGH9CqAXFcJjsDAlohim2U,17340
|
|
13
|
+
offgit/reconcile.py,sha256=7rssUVVlxPku0SQM3TDpw8-Cx0nk4AEvYEcX_TZJeVc,5743
|
|
14
|
+
offgit/transport.py,sha256=s6r-PnIa6_v8Q73I87RqxeQ8WKmcfGIcWrztek4IFmg,9879
|
|
15
|
+
offgit/server/__init__.py,sha256=KP_S8xqQHwGHY0_FrwzxlrKK1DyfRh5M0lFlH94-vfY,82
|
|
16
|
+
offgit/server/backup.py,sha256=wFV_86sd8AIAh5aybLog8brzLkZib5Dz7TSHaYr1Tpw,15352
|
|
17
|
+
offgit/server/cli.py,sha256=v5bKoSASIcuvPusu2ke3g-6QiqiPE-x7CtygPqsRjNM,12913
|
|
18
|
+
offgit/server/export.py,sha256=N7DrACvd6ZCG6g0sSA66rmYqE5bMRL9gAcixt3eRtFM,2684
|
|
19
|
+
offgit/server/health.py,sha256=33f9qEUCcBsNrWt7CF-XcHf9uSJjo51tS_fYC4JiSXE,1801
|
|
20
|
+
offgit/server/locks.py,sha256=9Mc8ZNawxAofN5UQzSaIPksxcztFkllA5mro17QrUq8,1485
|
|
21
|
+
offgit/server/migrate.py,sha256=ls8VRFnaZc9I-yjQn0Sa99TdAED8ZHZt6uBPFGmOjvA,2401
|
|
22
|
+
offgit/server/restore.py,sha256=UXsmve8Yo-0TZOxpZAG7WD4R5x-lshrYTgntFSBxsOo,8544
|
|
23
|
+
offgit/server/rpc.py,sha256=T6TEVsdUhkzvzhjELiWsZCOw93fnBwPFgbdjvXLIrNc,6583
|
|
24
|
+
offgit/server/schema.py,sha256=9awl9qYQOjrN4ogODpYFBCdVPDQTN3d1cOOP-f0DJlk,8265
|
|
25
|
+
offgit/server/settings.py,sha256=4KjTFvg3ikp-yQc1S6AR6N-Jaw0BflcggyaN6k8dty4,5074
|
|
26
|
+
offgit/server/store.py,sha256=5mODo5irLsa0WZ0XaQHHWarjXUFvzQeAoJVOUdqSwm4,27248
|
|
27
|
+
offgit/server/migrations/__init__.py,sha256=Ijm3I8-4FfBzk7Dj5VsBKKhPhGuduOk2pGinU_OPNYo,431
|
|
28
|
+
offgit/server/migrations/v001_initial.py,sha256=MXJ-1XQSAn9qhpVDYEeu91Vn2WK4U8cmSdaBfHjfSLY,1792
|
|
29
|
+
offgit-0.1.0.dist-info/METADATA,sha256=XdlVtl7pPzRDyWPpdIcrCIEzYpzwyAN9K41PXrzOS1E,6568
|
|
30
|
+
offgit-0.1.0.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
31
|
+
offgit-0.1.0.dist-info/entry_points.txt,sha256=QWLR5eTbkxAWvY_RB5N-QVzuvcL0Byuqp3LBxrNaZT0,82
|
|
32
|
+
offgit-0.1.0.dist-info/licenses/LICENSE,sha256=EWOftbiln5Lcppv29MnUmUf0QMmKGA5hR_uoyEP1Fnk,1076
|
|
33
|
+
offgit-0.1.0.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 offgit contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|