gitstore 0.2.1__tar.gz → 0.2.3__tar.gz
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.
- {gitstore-0.2.1 → gitstore-0.2.3}/PKG-INFO +10 -7
- {gitstore-0.2.1 → gitstore-0.2.3}/README.md +9 -6
- {gitstore-0.2.1 → gitstore-0.2.3}/pyproject.toml +1 -1
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore/client.py +19 -10
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore/github_ops.py +13 -2
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore.egg-info/PKG-INFO +10 -7
- {gitstore-0.2.1 → gitstore-0.2.3}/setup.cfg +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore/__init__.py +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore/config.py +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore/crypto_ops.py +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore.egg-info/SOURCES.txt +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore.egg-info/dependency_links.txt +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore.egg-info/requires.txt +0 -0
- {gitstore-0.2.1 → gitstore-0.2.3}/src/gitstore.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitstore
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Utilities to encrypt files/directories with utilitz and exchange them through GitHub repositories.
|
|
5
5
|
Author: artitzco
|
|
6
6
|
License: MIT
|
|
@@ -63,7 +63,7 @@ record = upload_to_github(
|
|
|
63
63
|
request_timeout=60, # default
|
|
64
64
|
security_level="high", # default
|
|
65
65
|
replace_existing=True, # default
|
|
66
|
-
|
|
66
|
+
force=False, # default
|
|
67
67
|
commit_message=None, # default: automatic message
|
|
68
68
|
)
|
|
69
69
|
print(record)
|
|
@@ -73,7 +73,7 @@ Upload behavior:
|
|
|
73
73
|
|
|
74
74
|
- computes `source_hash` from source content before encryption
|
|
75
75
|
- skips upload if same `name` already has same `source_hash`
|
|
76
|
-
- set `
|
|
76
|
+
- set `force=True` to upload even when the current source matches the remote metadata
|
|
77
77
|
- stores artifact as `vault/<name>.asc`
|
|
78
78
|
- stores metadata in `vault/index.json`
|
|
79
79
|
- removes temporary encrypted file after processing
|
|
@@ -109,11 +109,12 @@ folder/documento
|
|
|
109
109
|
from gitstore import restore_from_github
|
|
110
110
|
|
|
111
111
|
output_path = restore_from_github(
|
|
112
|
-
|
|
112
|
+
github_raw_url="https://raw.githubusercontent.com/USER/REPO/main/vault/documento_ventas_q2.asc",
|
|
113
113
|
password=None, # default: uses GITSTORE_PASSWORD
|
|
114
114
|
output_path=None, # default: restores in the current working directory
|
|
115
115
|
overwrite=False, # default
|
|
116
|
-
|
|
116
|
+
force=False, # default
|
|
117
|
+
use_urllib=False, # default: True uses urllib alternative route
|
|
117
118
|
)
|
|
118
119
|
print(output_path)
|
|
119
120
|
```
|
|
@@ -138,9 +139,11 @@ Tip:
|
|
|
138
139
|
|
|
139
140
|
Download behavior:
|
|
140
141
|
|
|
141
|
-
-
|
|
142
|
+
- expects RAW GitHub URLs (`raw.githubusercontent.com/...`) as primary input
|
|
143
|
+
- also accepts `github.com/.../blob/...` and normalizes automatically
|
|
142
144
|
- skips download when `output_path` already exists and matches the remote `source_hash` in `vault/index.json`
|
|
143
|
-
- set `
|
|
145
|
+
- set `force=True` to download even when the local output appears aligned
|
|
146
|
+
- set `use_urllib=True` to use the urllib alternative transport path
|
|
144
147
|
- downloads the encrypted `.asc` file to a temporary location
|
|
145
148
|
- restores files or directories automatically with `utilitz.crypto`
|
|
146
149
|
- removes the temporary encrypted file after restore
|
|
@@ -52,7 +52,7 @@ record = upload_to_github(
|
|
|
52
52
|
request_timeout=60, # default
|
|
53
53
|
security_level="high", # default
|
|
54
54
|
replace_existing=True, # default
|
|
55
|
-
|
|
55
|
+
force=False, # default
|
|
56
56
|
commit_message=None, # default: automatic message
|
|
57
57
|
)
|
|
58
58
|
print(record)
|
|
@@ -62,7 +62,7 @@ Upload behavior:
|
|
|
62
62
|
|
|
63
63
|
- computes `source_hash` from source content before encryption
|
|
64
64
|
- skips upload if same `name` already has same `source_hash`
|
|
65
|
-
- set `
|
|
65
|
+
- set `force=True` to upload even when the current source matches the remote metadata
|
|
66
66
|
- stores artifact as `vault/<name>.asc`
|
|
67
67
|
- stores metadata in `vault/index.json`
|
|
68
68
|
- removes temporary encrypted file after processing
|
|
@@ -98,11 +98,12 @@ folder/documento
|
|
|
98
98
|
from gitstore import restore_from_github
|
|
99
99
|
|
|
100
100
|
output_path = restore_from_github(
|
|
101
|
-
|
|
101
|
+
github_raw_url="https://raw.githubusercontent.com/USER/REPO/main/vault/documento_ventas_q2.asc",
|
|
102
102
|
password=None, # default: uses GITSTORE_PASSWORD
|
|
103
103
|
output_path=None, # default: restores in the current working directory
|
|
104
104
|
overwrite=False, # default
|
|
105
|
-
|
|
105
|
+
force=False, # default
|
|
106
|
+
use_urllib=False, # default: True uses urllib alternative route
|
|
106
107
|
)
|
|
107
108
|
print(output_path)
|
|
108
109
|
```
|
|
@@ -127,9 +128,11 @@ Tip:
|
|
|
127
128
|
|
|
128
129
|
Download behavior:
|
|
129
130
|
|
|
130
|
-
-
|
|
131
|
+
- expects RAW GitHub URLs (`raw.githubusercontent.com/...`) as primary input
|
|
132
|
+
- also accepts `github.com/.../blob/...` and normalizes automatically
|
|
131
133
|
- skips download when `output_path` already exists and matches the remote `source_hash` in `vault/index.json`
|
|
132
|
-
- set `
|
|
134
|
+
- set `force=True` to download even when the local output appears aligned
|
|
135
|
+
- set `use_urllib=True` to use the urllib alternative transport path
|
|
133
136
|
- downloads the encrypted `.asc` file to a temporary location
|
|
134
137
|
- restores files or directories automatically with `utilitz.crypto`
|
|
135
138
|
- removes the temporary encrypted file after restore
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "gitstore"
|
|
7
|
-
version = "0.2.
|
|
7
|
+
version = "0.2.3"
|
|
8
8
|
description = "Utilities to encrypt files/directories with utilitz and exchange them through GitHub repositories."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -7,10 +7,15 @@ import hmac
|
|
|
7
7
|
import re
|
|
8
8
|
from dataclasses import dataclass
|
|
9
9
|
from datetime import datetime, timezone
|
|
10
|
-
from pathlib import Path
|
|
11
|
-
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
|
|
12
12
|
from .config import GitStoreConfig
|
|
13
|
-
from .github_ops import
|
|
13
|
+
from .github_ops import (
|
|
14
|
+
download_raw_file,
|
|
15
|
+
download_raw_file_urllib,
|
|
16
|
+
git_add_commit_push,
|
|
17
|
+
normalize_github_file_url,
|
|
18
|
+
)
|
|
14
19
|
from .crypto_ops import decrypt_auto, encrypt_directory, encrypt_file
|
|
15
20
|
|
|
16
21
|
DEFAULT_PASSWORD_ENV_VAR = "GITSTORE_PASSWORD"
|
|
@@ -97,18 +102,19 @@ def _hmac_source(path: Path, secret: str) -> str:
|
|
|
97
102
|
|
|
98
103
|
|
|
99
104
|
def restore_from_github(
|
|
100
|
-
|
|
105
|
+
github_raw_url: str,
|
|
101
106
|
password: str | None = None,
|
|
102
107
|
output_path: str | None = None,
|
|
103
108
|
overwrite: bool = False,
|
|
104
|
-
|
|
109
|
+
force: bool = False,
|
|
110
|
+
use_urllib: bool = False,
|
|
105
111
|
request_timeout: int = 60,
|
|
106
112
|
password_env_var: str = DEFAULT_PASSWORD_ENV_VAR,
|
|
107
113
|
) -> str:
|
|
108
114
|
resolved_password = _resolve_password(password, password_env_var)
|
|
109
115
|
config = GitStoreConfig(password=resolved_password, request_timeout=request_timeout)
|
|
110
|
-
raw_url = normalize_github_file_url(
|
|
111
|
-
if output_path is not None and not overwrite and not
|
|
116
|
+
raw_url = normalize_github_file_url(github_raw_url)
|
|
117
|
+
if output_path is not None and not overwrite and not force:
|
|
112
118
|
existing_output = Path(output_path).expanduser().resolve()
|
|
113
119
|
if existing_output.exists():
|
|
114
120
|
remote_record = _load_remote_record_for_artifact(raw_url, request_timeout)
|
|
@@ -130,7 +136,10 @@ def restore_from_github(
|
|
|
130
136
|
temp_dir = Path(tempfile.mkdtemp(prefix="gitstore_download_"))
|
|
131
137
|
temp_file = temp_dir / "artifact.asc"
|
|
132
138
|
try:
|
|
133
|
-
|
|
139
|
+
if use_urllib:
|
|
140
|
+
download_raw_file_urllib(raw_url, str(temp_file), timeout=request_timeout)
|
|
141
|
+
else:
|
|
142
|
+
download_raw_file(raw_url, str(temp_file), timeout=request_timeout)
|
|
134
143
|
restored_path = decrypt_auto(
|
|
135
144
|
encrypted_path=str(temp_file),
|
|
136
145
|
config=config,
|
|
@@ -201,7 +210,7 @@ def upload_to_github(
|
|
|
201
210
|
security_level: str = "high",
|
|
202
211
|
commit_message: str | None = None,
|
|
203
212
|
replace_existing: bool = True,
|
|
204
|
-
|
|
213
|
+
force: bool = False,
|
|
205
214
|
) -> StoredArtifact:
|
|
206
215
|
if not repo_path:
|
|
207
216
|
raise ValueError("repo_path is required.")
|
|
@@ -227,7 +236,7 @@ def upload_to_github(
|
|
|
227
236
|
existing_record = manifest.get(name)
|
|
228
237
|
if existing_record:
|
|
229
238
|
existing_source_hash = str(existing_record.get("source_hash", "")).lower()
|
|
230
|
-
if existing_source_hash == source_hash.lower() and not
|
|
239
|
+
if existing_source_hash == source_hash.lower() and not force:
|
|
231
240
|
print(
|
|
232
241
|
f"[gitstore] Skip upload: '{name}' already up to date "
|
|
233
242
|
f"(source_hash={source_hash[:24]})."
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import subprocess
|
|
2
|
-
|
|
1
|
+
import subprocess
|
|
2
|
+
import urllib.request
|
|
3
|
+
from pathlib import Path
|
|
3
4
|
|
|
4
5
|
import requests
|
|
5
6
|
|
|
@@ -40,6 +41,16 @@ def download_raw_file(raw_url: str, output_path: str, timeout: int = 60) -> str:
|
|
|
40
41
|
return str(destination)
|
|
41
42
|
|
|
42
43
|
|
|
44
|
+
def download_raw_file_urllib(raw_url: str, output_path: str, timeout: int = 60) -> str:
|
|
45
|
+
destination = Path(output_path).expanduser().resolve()
|
|
46
|
+
destination.parent.mkdir(parents=True, exist_ok=True)
|
|
47
|
+
with urllib.request.urlopen(raw_url, timeout=timeout) as response:
|
|
48
|
+
content = response.read()
|
|
49
|
+
with open(destination, "wb") as f:
|
|
50
|
+
f.write(content)
|
|
51
|
+
return str(destination)
|
|
52
|
+
|
|
53
|
+
|
|
43
54
|
def git_add_commit_push(
|
|
44
55
|
repo_path: str,
|
|
45
56
|
paths_in_repo: list[str],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: gitstore
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.3
|
|
4
4
|
Summary: Utilities to encrypt files/directories with utilitz and exchange them through GitHub repositories.
|
|
5
5
|
Author: artitzco
|
|
6
6
|
License: MIT
|
|
@@ -63,7 +63,7 @@ record = upload_to_github(
|
|
|
63
63
|
request_timeout=60, # default
|
|
64
64
|
security_level="high", # default
|
|
65
65
|
replace_existing=True, # default
|
|
66
|
-
|
|
66
|
+
force=False, # default
|
|
67
67
|
commit_message=None, # default: automatic message
|
|
68
68
|
)
|
|
69
69
|
print(record)
|
|
@@ -73,7 +73,7 @@ Upload behavior:
|
|
|
73
73
|
|
|
74
74
|
- computes `source_hash` from source content before encryption
|
|
75
75
|
- skips upload if same `name` already has same `source_hash`
|
|
76
|
-
- set `
|
|
76
|
+
- set `force=True` to upload even when the current source matches the remote metadata
|
|
77
77
|
- stores artifact as `vault/<name>.asc`
|
|
78
78
|
- stores metadata in `vault/index.json`
|
|
79
79
|
- removes temporary encrypted file after processing
|
|
@@ -109,11 +109,12 @@ folder/documento
|
|
|
109
109
|
from gitstore import restore_from_github
|
|
110
110
|
|
|
111
111
|
output_path = restore_from_github(
|
|
112
|
-
|
|
112
|
+
github_raw_url="https://raw.githubusercontent.com/USER/REPO/main/vault/documento_ventas_q2.asc",
|
|
113
113
|
password=None, # default: uses GITSTORE_PASSWORD
|
|
114
114
|
output_path=None, # default: restores in the current working directory
|
|
115
115
|
overwrite=False, # default
|
|
116
|
-
|
|
116
|
+
force=False, # default
|
|
117
|
+
use_urllib=False, # default: True uses urllib alternative route
|
|
117
118
|
)
|
|
118
119
|
print(output_path)
|
|
119
120
|
```
|
|
@@ -138,9 +139,11 @@ Tip:
|
|
|
138
139
|
|
|
139
140
|
Download behavior:
|
|
140
141
|
|
|
141
|
-
-
|
|
142
|
+
- expects RAW GitHub URLs (`raw.githubusercontent.com/...`) as primary input
|
|
143
|
+
- also accepts `github.com/.../blob/...` and normalizes automatically
|
|
142
144
|
- skips download when `output_path` already exists and matches the remote `source_hash` in `vault/index.json`
|
|
143
|
-
- set `
|
|
145
|
+
- set `force=True` to download even when the local output appears aligned
|
|
146
|
+
- set `use_urllib=True` to use the urllib alternative transport path
|
|
144
147
|
- downloads the encrypted `.asc` file to a temporary location
|
|
145
148
|
- restores files or directories automatically with `utilitz.crypto`
|
|
146
149
|
- removes the temporary encrypted file after restore
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|