pkgmgr-kunrunic 0.1.1.dev2__tar.gz → 0.1.1.dev4__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.
- {pkgmgr_kunrunic-0.1.1.dev2/pkgmgr_kunrunic.egg-info → pkgmgr_kunrunic-0.1.1.dev4}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/__init__.py +1 -1
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/cli.py +19 -2
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/config.py +25 -1
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/release.py +208 -4
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4/pkgmgr_kunrunic.egg-info}/PKG-INFO +1 -1
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/SOURCES.txt +3 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/top_level.txt +2 -0
- pkgmgr_kunrunic-0.1.1.dev4/plugin/export_cksum.py +354 -0
- pkgmgr_kunrunic-0.1.1.dev4/plugin/export_pkgstore.py +117 -0
- pkgmgr_kunrunic-0.1.1.dev4/plugin/export_source_review.py +499 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/tests/test_release.py +16 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/LICENSE +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/README.md +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/__main__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/collectors/__init__.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/collectors/base.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/collectors/checksums.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/points.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/shell_integration.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/templates/pkg.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/templates/pkgmgr.yaml.sample +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr/watch.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/dependency_links.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/entry_points.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/not-zip-safe +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/requires.txt +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pyproject.toml +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/setup.cfg +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/tests/test_cli_install.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/tests/test_config.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/tests/test_progress.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/tests/test_snapshot.py +0 -0
- {pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/tools/echo_args.py +0 -0
|
@@ -161,7 +161,10 @@ def _add_point(sub):
|
|
|
161
161
|
def build_parser():
|
|
162
162
|
if argparse is None:
|
|
163
163
|
raise RuntimeError("argparse not available; install argparse")
|
|
164
|
-
parser = argparse.ArgumentParser(
|
|
164
|
+
parser = argparse.ArgumentParser(
|
|
165
|
+
prog="pkgmgr",
|
|
166
|
+
description="Pkg manager CLI v%s" % __version__,
|
|
167
|
+
)
|
|
165
168
|
# keep %(prog)s for argparse's mapping and append package version
|
|
166
169
|
parser.add_argument("-V", "--version", action="version", version="%(prog)s " + __version__)
|
|
167
170
|
parser.add_argument(
|
|
@@ -217,20 +220,24 @@ def _handle_snapshot(args):
|
|
|
217
220
|
def _handle_create_pkg(args):
|
|
218
221
|
cfg = config.load_main(args.config)
|
|
219
222
|
release.create_pkg(cfg, args.pkg_id)
|
|
223
|
+
_run_auto_actions(cfg, "create_pkg", config_path=args.config)
|
|
220
224
|
return 0
|
|
221
225
|
|
|
222
226
|
def _handle_update_pkg(args):
|
|
223
227
|
cfg = config.load_main(args.config)
|
|
224
228
|
if args.release:
|
|
225
229
|
release.finalize_pkg_release(cfg, args.pkg_id)
|
|
230
|
+
_run_auto_actions(cfg, "update_pkg_release", config_path=args.config)
|
|
226
231
|
return 0
|
|
227
232
|
release.update_pkg(cfg, args.pkg_id)
|
|
233
|
+
_run_auto_actions(cfg, "update_pkg", config_path=args.config)
|
|
228
234
|
return 0
|
|
229
235
|
|
|
230
236
|
|
|
231
237
|
def _handle_close_pkg(args):
|
|
232
238
|
cfg = config.load_main(args.config)
|
|
233
239
|
release.close_pkg(cfg, args.pkg_id)
|
|
240
|
+
_run_auto_actions(cfg, "close_pkg", config_path=args.config)
|
|
234
241
|
return 0
|
|
235
242
|
|
|
236
243
|
|
|
@@ -261,10 +268,20 @@ def _handle_actions(args):
|
|
|
261
268
|
return 0
|
|
262
269
|
_print_actions(actions)
|
|
263
270
|
return 0
|
|
264
|
-
release.run_actions(
|
|
271
|
+
release.run_actions(
|
|
272
|
+
cfg, [args.name], extra_args=args.action_args, config_path=args.config
|
|
273
|
+
)
|
|
265
274
|
return 0
|
|
266
275
|
|
|
267
276
|
|
|
277
|
+
def _run_auto_actions(cfg, event, config_path=None):
|
|
278
|
+
auto_actions = cfg.get("auto_actions") or {}
|
|
279
|
+
names = auto_actions.get(event) or []
|
|
280
|
+
if not names:
|
|
281
|
+
return []
|
|
282
|
+
return release.run_actions(cfg, names, config_path=config_path)
|
|
283
|
+
|
|
284
|
+
|
|
268
285
|
def _print_actions(actions):
|
|
269
286
|
ordered = sorted(actions.keys())
|
|
270
287
|
print("[actions] available:")
|
|
@@ -75,6 +75,12 @@ actions:
|
|
|
75
75
|
noti_email:
|
|
76
76
|
- cmd: sh noti_email.sh
|
|
77
77
|
cwd: /app/script
|
|
78
|
+
|
|
79
|
+
auto_actions:
|
|
80
|
+
create_pkg: []
|
|
81
|
+
update_pkg: []
|
|
82
|
+
update_pkg_release: []
|
|
83
|
+
close_pkg: []
|
|
78
84
|
"""
|
|
79
85
|
|
|
80
86
|
PKG_TEMPLATE = """\
|
|
@@ -104,6 +110,12 @@ MAIN_DEFAULTS = {
|
|
|
104
110
|
"watch": {"interval_sec": 60, "on_change": []},
|
|
105
111
|
"collectors": {"enabled": ["checksums"]},
|
|
106
112
|
"actions": {},
|
|
113
|
+
"auto_actions": {
|
|
114
|
+
"create_pkg": [],
|
|
115
|
+
"update_pkg": [],
|
|
116
|
+
"update_pkg_release": [],
|
|
117
|
+
"close_pkg": [],
|
|
118
|
+
},
|
|
107
119
|
}
|
|
108
120
|
|
|
109
121
|
|
|
@@ -167,6 +179,16 @@ def _validate_watch(watch_cfg):
|
|
|
167
179
|
return {"interval_sec": interval, "on_change": on_change}
|
|
168
180
|
|
|
169
181
|
|
|
182
|
+
def _validate_auto_actions(auto_actions):
|
|
183
|
+
cfg = auto_actions if isinstance(auto_actions, dict) else {}
|
|
184
|
+
return {
|
|
185
|
+
"create_pkg": _ensure_list_of_strings(cfg.get("create_pkg"), "auto_actions.create_pkg"),
|
|
186
|
+
"update_pkg": _ensure_list_of_strings(cfg.get("update_pkg"), "auto_actions.update_pkg"),
|
|
187
|
+
"update_pkg_release": _ensure_list_of_strings(cfg.get("update_pkg_release"), "auto_actions.update_pkg_release"),
|
|
188
|
+
"close_pkg": _ensure_list_of_strings(cfg.get("close_pkg"), "auto_actions.close_pkg"),
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
|
|
170
192
|
def _validate_main_config(data):
|
|
171
193
|
if not isinstance(data, dict):
|
|
172
194
|
raise RuntimeError("main config must be a mapping")
|
|
@@ -197,6 +219,7 @@ def _validate_main_config(data):
|
|
|
197
219
|
}
|
|
198
220
|
|
|
199
221
|
cfg["actions"] = _validate_actions(cfg.get("actions"))
|
|
222
|
+
cfg["auto_actions"] = _validate_auto_actions(cfg.get("auto_actions"))
|
|
200
223
|
|
|
201
224
|
return cfg
|
|
202
225
|
|
|
@@ -359,7 +382,7 @@ def load_main(path=None, base_dir=None, allow_interactive=True):
|
|
|
359
382
|
abs_path = os.path.abspath(path)
|
|
360
383
|
if not os.path.exists(abs_path):
|
|
361
384
|
raise RuntimeError("config not found: %s" % abs_path)
|
|
362
|
-
with open(abs_path, "r") as f:
|
|
385
|
+
with open(abs_path, "r", encoding="utf-8") as f:
|
|
363
386
|
data = yaml.safe_load(f) or {}
|
|
364
387
|
return _validate_main_config(data)
|
|
365
388
|
|
|
@@ -380,5 +403,6 @@ def describe_expected_fields():
|
|
|
380
403
|
- cmd: shell command string (required, often relative to cwd)
|
|
381
404
|
- cwd: working directory (optional)
|
|
382
405
|
- env: key/value env overrides for that command only (optional)
|
|
406
|
+
auto_actions: mapping of lifecycle events to action names (create_pkg/update_pkg/update_pkg_release/close_pkg)
|
|
383
407
|
"""
|
|
384
408
|
).strip()
|
|
@@ -36,6 +36,14 @@ def _pkg_state_path(pkg_id):
|
|
|
36
36
|
return os.path.join(_pkg_state_dir(pkg_id), "state.json")
|
|
37
37
|
|
|
38
38
|
|
|
39
|
+
def _pkg_summary_path():
|
|
40
|
+
return os.path.join(config.DEFAULT_STATE_DIR, "pkg-summary.json")
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _pkg_release_history_dir(pkg_id):
|
|
44
|
+
return os.path.join(config.DEFAULT_STATE_DIR, "pkg", str(pkg_id), "release")
|
|
45
|
+
|
|
46
|
+
|
|
39
47
|
def _timestamp():
|
|
40
48
|
return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime())
|
|
41
49
|
|
|
@@ -75,6 +83,131 @@ def _write_pkg_state(pkg_id, status, extra=None):
|
|
|
75
83
|
return state
|
|
76
84
|
|
|
77
85
|
|
|
86
|
+
def _parse_ts(value):
|
|
87
|
+
if not value:
|
|
88
|
+
return 0
|
|
89
|
+
for fmt in ("%Y-%m-%dT%H:%M:%S", "%Y%m%dT%H%M%S"):
|
|
90
|
+
try:
|
|
91
|
+
return int(time.mktime(time.strptime(str(value), fmt)))
|
|
92
|
+
except Exception:
|
|
93
|
+
continue
|
|
94
|
+
return 0
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def _load_pkg_summary():
|
|
98
|
+
path = _pkg_summary_path()
|
|
99
|
+
if not os.path.exists(path):
|
|
100
|
+
return {"generated_at": _timestamp(), "pkgs": []}
|
|
101
|
+
try:
|
|
102
|
+
with open(path, "r") as f:
|
|
103
|
+
data = json.load(f)
|
|
104
|
+
if isinstance(data, dict) and isinstance(data.get("pkgs"), list):
|
|
105
|
+
return data
|
|
106
|
+
except Exception:
|
|
107
|
+
pass
|
|
108
|
+
return {"generated_at": _timestamp(), "pkgs": []}
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
def _find_latest_update(pkg_id):
|
|
112
|
+
updates_dir = os.path.join(config.DEFAULT_STATE_DIR, "pkg", str(pkg_id), "updates")
|
|
113
|
+
if not os.path.isdir(updates_dir):
|
|
114
|
+
return None, None
|
|
115
|
+
candidates = []
|
|
116
|
+
for name in os.listdir(updates_dir):
|
|
117
|
+
if not name.startswith("update-") or not name.endswith(".json"):
|
|
118
|
+
continue
|
|
119
|
+
ts = name[len("update-"):-len(".json")]
|
|
120
|
+
candidates.append((ts, name))
|
|
121
|
+
if not candidates:
|
|
122
|
+
return None, None
|
|
123
|
+
candidates.sort(key=lambda item: _parse_ts(item[0]))
|
|
124
|
+
latest_ts, latest_name = candidates[-1]
|
|
125
|
+
return os.path.join(updates_dir, latest_name), latest_ts
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
def _build_pkg_summary_entry(pkg_id):
|
|
129
|
+
state = _load_pkg_state(pkg_id) or {}
|
|
130
|
+
update_path, update_ts = _find_latest_update(pkg_id)
|
|
131
|
+
update_data = {}
|
|
132
|
+
if update_path:
|
|
133
|
+
try:
|
|
134
|
+
with open(update_path, "r") as f:
|
|
135
|
+
update_data = json.load(f) or {}
|
|
136
|
+
except Exception:
|
|
137
|
+
update_data = {}
|
|
138
|
+
git_info = update_data.get("git") or {}
|
|
139
|
+
release_info = update_data.get("release") or []
|
|
140
|
+
checksums = update_data.get("checksums") or {}
|
|
141
|
+
git_files = checksums.get("git_files") or {}
|
|
142
|
+
release_files = checksums.get("release_files") or {}
|
|
143
|
+
|
|
144
|
+
entry = {
|
|
145
|
+
"pkg_id": str(pkg_id),
|
|
146
|
+
"status": state.get("status") or "unknown",
|
|
147
|
+
"opened_at": state.get("opened_at"),
|
|
148
|
+
"updated_at": state.get("updated_at"),
|
|
149
|
+
"closed_at": state.get("closed_at"),
|
|
150
|
+
"last_update_id": os.path.basename(update_path) if update_path else None,
|
|
151
|
+
"last_update_at": update_ts,
|
|
152
|
+
"git": {
|
|
153
|
+
"keywords": git_info.get("keywords") or [],
|
|
154
|
+
"commit_count": len(git_info.get("commits") or []),
|
|
155
|
+
},
|
|
156
|
+
"release": {
|
|
157
|
+
"bundle_count": len(release_info),
|
|
158
|
+
"roots": sorted({b.get("root") for b in release_info if b.get("root")}),
|
|
159
|
+
"names": sorted({b.get("release_name") for b in release_info if b.get("release_name")}),
|
|
160
|
+
},
|
|
161
|
+
"artifacts": {
|
|
162
|
+
"git_files": len(git_files),
|
|
163
|
+
"release_files": len(release_files),
|
|
164
|
+
},
|
|
165
|
+
}
|
|
166
|
+
return entry
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
def _update_pkg_summary(pkg_id):
|
|
170
|
+
data = _load_pkg_summary()
|
|
171
|
+
pkgs = data.get("pkgs") or []
|
|
172
|
+
by_id = {p.get("pkg_id"): p for p in pkgs if isinstance(p, dict)}
|
|
173
|
+
entry = _build_pkg_summary_entry(pkg_id)
|
|
174
|
+
by_id[entry["pkg_id"]] = entry
|
|
175
|
+
|
|
176
|
+
def _sort_key(item):
|
|
177
|
+
status = item.get("status") or ""
|
|
178
|
+
updated_ts = max(_parse_ts(item.get("updated_at")), _parse_ts(item.get("last_update_at")))
|
|
179
|
+
return (0 if status == "open" else 1, -updated_ts)
|
|
180
|
+
|
|
181
|
+
ordered = sorted(by_id.values(), key=_sort_key)
|
|
182
|
+
data = {
|
|
183
|
+
"generated_at": _timestamp(),
|
|
184
|
+
"pkgs": ordered,
|
|
185
|
+
}
|
|
186
|
+
path = _pkg_summary_path()
|
|
187
|
+
if not os.path.exists(os.path.dirname(path)):
|
|
188
|
+
os.makedirs(os.path.dirname(path))
|
|
189
|
+
with open(path, "w") as f:
|
|
190
|
+
json.dump(data, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _write_release_history(pkg_id, run_at, bundles):
|
|
194
|
+
if not bundles:
|
|
195
|
+
return None
|
|
196
|
+
rel_dir = _pkg_release_history_dir(pkg_id)
|
|
197
|
+
if not os.path.exists(rel_dir):
|
|
198
|
+
os.makedirs(rel_dir)
|
|
199
|
+
payload = {
|
|
200
|
+
"pkg_id": str(pkg_id),
|
|
201
|
+
"run_at": run_at,
|
|
202
|
+
"generated_at": _timestamp(),
|
|
203
|
+
"bundles": bundles,
|
|
204
|
+
}
|
|
205
|
+
out_path = os.path.join(rel_dir, "release-%s.json" % run_at)
|
|
206
|
+
with open(out_path, "w") as f:
|
|
207
|
+
json.dump(payload, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
208
|
+
return out_path
|
|
209
|
+
|
|
210
|
+
|
|
78
211
|
def pkg_is_closed(pkg_id):
|
|
79
212
|
state = _load_pkg_state(pkg_id)
|
|
80
213
|
return bool(state and state.get("status") == "closed")
|
|
@@ -122,6 +255,7 @@ def create_pkg(cfg, pkg_id):
|
|
|
122
255
|
else:
|
|
123
256
|
print("[create-pkg] baseline already exists; skipping baseline creation")
|
|
124
257
|
_write_pkg_state(pkg_id, "open")
|
|
258
|
+
_update_pkg_summary(pkg_id)
|
|
125
259
|
print("[create-pkg] prepared %s" % dest)
|
|
126
260
|
|
|
127
261
|
|
|
@@ -135,6 +269,7 @@ def close_pkg(cfg, pkg_id):
|
|
|
135
269
|
with open(marker, "w") as f:
|
|
136
270
|
f.write("closed\n")
|
|
137
271
|
_write_pkg_state(pkg_id, "closed")
|
|
272
|
+
_update_pkg_summary(pkg_id)
|
|
138
273
|
print("[close-pkg] marked closed: %s" % dest)
|
|
139
274
|
|
|
140
275
|
|
|
@@ -150,7 +285,7 @@ def collect_for_pkg(cfg, pkg_id, collectors=None):
|
|
|
150
285
|
|
|
151
286
|
|
|
152
287
|
|
|
153
|
-
def run_actions(cfg, names, extra_args=None):
|
|
288
|
+
def run_actions(cfg, names, extra_args=None, config_path=None):
|
|
154
289
|
"""Run configured actions by name. Returns result list."""
|
|
155
290
|
actions = cfg.get("actions", {}) or {}
|
|
156
291
|
if not names:
|
|
@@ -180,6 +315,9 @@ def run_actions(cfg, names, extra_args=None):
|
|
|
180
315
|
if not cmd:
|
|
181
316
|
print("[actions] skip empty cmd for %s #%d" % (name, idx + 1))
|
|
182
317
|
continue
|
|
318
|
+
if config_path:
|
|
319
|
+
env = dict(env or {})
|
|
320
|
+
env.setdefault("PKGMGR_CONFIG", config_path)
|
|
183
321
|
if extra_suffix:
|
|
184
322
|
cmd = "%s%s" % (cmd, extra_suffix)
|
|
185
323
|
rc = _run_cmd(cmd, cwd=cwd, env=env, label="%s #%d" % (name, idx + 1))
|
|
@@ -260,6 +398,60 @@ def _git_repo_root(pkg_root, git_cfg):
|
|
|
260
398
|
return None
|
|
261
399
|
|
|
262
400
|
|
|
401
|
+
def _text_type():
|
|
402
|
+
try:
|
|
403
|
+
return unicode # type: ignore[name-defined]
|
|
404
|
+
except Exception:
|
|
405
|
+
return str
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def _decode_git_output(raw, encodings):
|
|
409
|
+
if raw is None:
|
|
410
|
+
return ""
|
|
411
|
+
text_type = _text_type()
|
|
412
|
+
if isinstance(raw, text_type):
|
|
413
|
+
return raw
|
|
414
|
+
if not encodings:
|
|
415
|
+
encodings = []
|
|
416
|
+
candidates = [e for e in encodings if e]
|
|
417
|
+
candidates.extend(["utf-8", "euc-kr", "cp949"])
|
|
418
|
+
best_text = None
|
|
419
|
+
best_score = None
|
|
420
|
+
for enc in candidates:
|
|
421
|
+
try:
|
|
422
|
+
text = raw.decode(enc, errors="replace")
|
|
423
|
+
except Exception:
|
|
424
|
+
continue
|
|
425
|
+
score = text.count(u"\ufffd")
|
|
426
|
+
if best_score is None or score < best_score:
|
|
427
|
+
best_score = score
|
|
428
|
+
best_text = text
|
|
429
|
+
if score == 0:
|
|
430
|
+
break
|
|
431
|
+
if best_text is not None:
|
|
432
|
+
return best_text
|
|
433
|
+
try:
|
|
434
|
+
return raw.decode("utf-8", errors="replace")
|
|
435
|
+
except Exception:
|
|
436
|
+
return str(raw)
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
def _git_output_encoding(repo_root):
|
|
440
|
+
for key in ("i18n.logOutputEncoding", "i18n.commitEncoding"):
|
|
441
|
+
try:
|
|
442
|
+
out = subprocess.check_output(
|
|
443
|
+
["git", "config", "--get", key],
|
|
444
|
+
cwd=repo_root,
|
|
445
|
+
stderr=subprocess.STDOUT,
|
|
446
|
+
universal_newlines=True,
|
|
447
|
+
).strip()
|
|
448
|
+
except Exception:
|
|
449
|
+
out = ""
|
|
450
|
+
if out:
|
|
451
|
+
return out
|
|
452
|
+
return "utf-8"
|
|
453
|
+
|
|
454
|
+
|
|
263
455
|
def _collect_git_hits(pkg_cfg, pkg_root):
|
|
264
456
|
git_cfg = pkg_cfg.get("git") or {}
|
|
265
457
|
keywords = [str(k) for k in (git_cfg.get("keywords") or []) if str(k).strip()]
|
|
@@ -277,6 +469,7 @@ def _collect_git_hits(pkg_cfg, pkg_root):
|
|
|
277
469
|
commits = {}
|
|
278
470
|
current = None
|
|
279
471
|
|
|
472
|
+
output_encoding = _git_output_encoding(repo_root)
|
|
280
473
|
for kw in keywords:
|
|
281
474
|
cmd = [
|
|
282
475
|
"git",
|
|
@@ -294,7 +487,13 @@ def _collect_git_hits(pkg_cfg, pkg_root):
|
|
|
294
487
|
if until:
|
|
295
488
|
cmd.append("--until=%s" % until)
|
|
296
489
|
try:
|
|
297
|
-
|
|
490
|
+
out_raw = subprocess.check_output(
|
|
491
|
+
cmd,
|
|
492
|
+
cwd=repo_root,
|
|
493
|
+
stderr=subprocess.STDOUT,
|
|
494
|
+
universal_newlines=False,
|
|
495
|
+
)
|
|
496
|
+
out = _decode_git_output(out_raw, [output_encoding])
|
|
298
497
|
except Exception as e:
|
|
299
498
|
print("[git] log failed for keyword %s: %s" % (kw, str(e)))
|
|
300
499
|
continue
|
|
@@ -322,12 +521,13 @@ def _collect_git_hits(pkg_cfg, pkg_root):
|
|
|
322
521
|
c["commit"] = c.get("hash")
|
|
323
522
|
# fetch author and full commit message body for richer context
|
|
324
523
|
try:
|
|
325
|
-
|
|
524
|
+
info_raw = subprocess.check_output(
|
|
326
525
|
["git", "show", "-s", "--format=%an\t%ae\t%ad%n%s%n%b", c["hash"]],
|
|
327
526
|
cwd=repo_root,
|
|
328
527
|
stderr=subprocess.STDOUT,
|
|
329
|
-
universal_newlines=
|
|
528
|
+
universal_newlines=False,
|
|
330
529
|
)
|
|
530
|
+
info = _decode_git_output(info_raw, [output_encoding])
|
|
331
531
|
header, _, body = info.partition("\n")
|
|
332
532
|
parts = header.split("\t")
|
|
333
533
|
c["author_name"] = parts[0] if len(parts) > 0 else ""
|
|
@@ -661,6 +861,8 @@ def _prepare_release(pkg_dir, pkg_cfg):
|
|
|
661
861
|
"root": root,
|
|
662
862
|
"release_dir": release_dir,
|
|
663
863
|
"release_name": release_name,
|
|
864
|
+
"created_at": ts,
|
|
865
|
+
"files": all_files,
|
|
664
866
|
"copied": copied,
|
|
665
867
|
"skipped": skipped,
|
|
666
868
|
"added": added,
|
|
@@ -824,4 +1026,6 @@ def update_pkg(cfg, pkg_id):
|
|
|
824
1026
|
with open(out_path, "w") as f:
|
|
825
1027
|
json.dump(data, f, ensure_ascii=False, indent=2, sort_keys=True)
|
|
826
1028
|
print("[update-pkg] wrote %s" % out_path)
|
|
1029
|
+
_write_release_history(pkg_id, ts, release_bundle)
|
|
1030
|
+
_update_pkg_summary(pkg_id)
|
|
827
1031
|
return out_path
|
{pkgmgr_kunrunic-0.1.1.dev2 → pkgmgr_kunrunic-0.1.1.dev4}/pkgmgr_kunrunic.egg-info/SOURCES.txt
RENAMED
|
@@ -22,6 +22,9 @@ pkgmgr_kunrunic.egg-info/entry_points.txt
|
|
|
22
22
|
pkgmgr_kunrunic.egg-info/not-zip-safe
|
|
23
23
|
pkgmgr_kunrunic.egg-info/requires.txt
|
|
24
24
|
pkgmgr_kunrunic.egg-info/top_level.txt
|
|
25
|
+
plugin/export_cksum.py
|
|
26
|
+
plugin/export_pkgstore.py
|
|
27
|
+
plugin/export_source_review.py
|
|
25
28
|
tests/test_cli_install.py
|
|
26
29
|
tests/test_config.py
|
|
27
30
|
tests/test_progress.py
|