gitstore 0.2.2__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.2 → gitstore-0.2.3}/PKG-INFO +7 -5
- {gitstore-0.2.2 → gitstore-0.2.3}/README.md +6 -4
- {gitstore-0.2.2 → gitstore-0.2.3}/pyproject.toml +1 -1
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore/client.py +17 -8
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore/github_ops.py +13 -2
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore.egg-info/PKG-INFO +7 -5
- {gitstore-0.2.2 → gitstore-0.2.3}/setup.cfg +0 -0
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore/__init__.py +0 -0
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore/config.py +0 -0
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore/crypto_ops.py +0 -0
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore.egg-info/SOURCES.txt +0 -0
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore.egg-info/dependency_links.txt +0 -0
- {gitstore-0.2.2 → gitstore-0.2.3}/src/gitstore.egg-info/requires.txt +0 -0
- {gitstore-0.2.2 → 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
|
|
@@ -113,7 +113,8 @@ output_path = restore_from_github(
|
|
|
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
|
```
|
|
@@ -141,7 +142,8 @@ Download behavior:
|
|
|
141
142
|
- expects RAW GitHub URLs (`raw.githubusercontent.com/...`) as primary input
|
|
142
143
|
- also accepts `github.com/.../blob/...` and normalizes automatically
|
|
143
144
|
- skips download when `output_path` already exists and matches the remote `source_hash` in `vault/index.json`
|
|
144
|
-
- 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
|
|
145
147
|
- downloads the encrypted `.asc` file to a temporary location
|
|
146
148
|
- restores files or directories automatically with `utilitz.crypto`
|
|
147
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
|
|
@@ -102,7 +102,8 @@ output_path = restore_from_github(
|
|
|
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
|
```
|
|
@@ -130,7 +131,8 @@ Download behavior:
|
|
|
130
131
|
- expects RAW GitHub URLs (`raw.githubusercontent.com/...`) as primary input
|
|
131
132
|
- also accepts `github.com/.../blob/...` and normalizes automatically
|
|
132
133
|
- skips download when `output_path` already exists and matches the remote `source_hash` in `vault/index.json`
|
|
133
|
-
- 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
|
|
134
136
|
- downloads the encrypted `.asc` file to a temporary location
|
|
135
137
|
- restores files or directories automatically with `utilitz.crypto`
|
|
136
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"
|
|
@@ -101,14 +106,15 @@ def restore_from_github(
|
|
|
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
116
|
raw_url = normalize_github_file_url(github_raw_url)
|
|
111
|
-
if output_path is not None and not overwrite and not
|
|
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
|
|
@@ -113,7 +113,8 @@ output_path = restore_from_github(
|
|
|
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
|
```
|
|
@@ -141,7 +142,8 @@ Download behavior:
|
|
|
141
142
|
- expects RAW GitHub URLs (`raw.githubusercontent.com/...`) as primary input
|
|
142
143
|
- also accepts `github.com/.../blob/...` and normalizes automatically
|
|
143
144
|
- skips download when `output_path` already exists and matches the remote `source_hash` in `vault/index.json`
|
|
144
|
-
- 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
|
|
145
147
|
- downloads the encrypted `.asc` file to a temporary location
|
|
146
148
|
- restores files or directories automatically with `utilitz.crypto`
|
|
147
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
|