repo-nexus 0.5.3 → 0.5.4
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.
- package/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/rnex +44 -16
package/CHANGELOG.md
CHANGED
|
@@ -17,6 +17,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
17
17
|
- Workspace schema migration in `rnex update` and `rnex fix -y` non-destructively inserts `git_hooks` into older configurations.
|
|
18
18
|
- `rnex status` and `rnex hooks status` display configuration state alongside runtime Git hooks status.
|
|
19
19
|
|
|
20
|
+
### Fixed
|
|
21
|
+
- **Git Hooks Self-Rewrite & Wrapper Preservation**:
|
|
22
|
+
- Resolved self-rewrite bug where `rnex hooks run post-merge` invoked `cmd_fix`, which truncated and replaced `.rnex/hooks/post-merge` while the shell interpreter was actively executing it.
|
|
23
|
+
- Added in-hook execution guard (`_RNEX_INSIDE_HOOK=1`) preventing hook script regeneration during active hook dispatch.
|
|
24
|
+
- Preserved custom / repository-owned wrappers in `.rnex/hooks/` that are not auto-managed by `rnex`.
|
|
25
|
+
- Added `cmp -s` check before writing hook files to eliminate unnecessary file churn and in-place overwrites.
|
|
26
|
+
- Automatically chain to existing repository-owned `.githooks/` scripts if present.
|
|
27
|
+
|
|
20
28
|
## [0.5.1] - 2026-10-08
|
|
21
29
|
|
|
22
30
|
### Added
|
package/package.json
CHANGED
package/rnex
CHANGED
|
@@ -1258,22 +1258,35 @@ upgrade_workspace_config() {
|
|
|
1258
1258
|
_create_hook_script() {
|
|
1259
1259
|
_dst="$1"
|
|
1260
1260
|
_hook_type="$2"
|
|
1261
|
-
|
|
1261
|
+
|
|
1262
|
+
# Preserve custom / repository-owned wrappers that are not auto-managed by rnex
|
|
1263
|
+
if [ -f "$_dst" ] && ! grep -q "Managed automatically by rnex" "$_dst" 2>/dev/null; then
|
|
1264
|
+
return 0
|
|
1265
|
+
fi
|
|
1266
|
+
|
|
1267
|
+
_sub_tmp="$(mktemp)"
|
|
1268
|
+
cat > "$_sub_tmp" <<HOOK_EOF
|
|
1262
1269
|
#!/bin/sh
|
|
1263
|
-
# Repo Nexus Git Hook:
|
|
1270
|
+
# Repo Nexus Git Hook: $_hook_type
|
|
1264
1271
|
# Managed automatically by rnex. Do not edit manually.
|
|
1265
1272
|
|
|
1266
|
-
_dir="
|
|
1273
|
+
_dir="\$(cd "\$(dirname "\$0")/../.." 2>/dev/null && pwd -P)"
|
|
1267
1274
|
if command -v rnex >/dev/null 2>&1; then
|
|
1268
|
-
rnex hooks run
|
|
1269
|
-
elif [ -f "
|
|
1270
|
-
"
|
|
1275
|
+
rnex hooks run $_hook_type "\$@"
|
|
1276
|
+
elif [ -f "\$_dir/rnex" ]; then
|
|
1277
|
+
"\$_dir/rnex" hooks run $_hook_type "\$@"
|
|
1271
1278
|
fi
|
|
1272
1279
|
HOOK_EOF
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1280
|
+
|
|
1281
|
+
chmod +x "$_sub_tmp"
|
|
1282
|
+
|
|
1283
|
+
# Avoid rewriting / modifying file if already identical (prevents inode churn & self-rewrite)
|
|
1284
|
+
if [ -f "$_dst" ] && cmp -s "$_sub_tmp" "$_dst"; then
|
|
1285
|
+
rm -f "$_sub_tmp"
|
|
1286
|
+
return 0
|
|
1287
|
+
fi
|
|
1288
|
+
|
|
1289
|
+
mv "$_sub_tmp" "$_dst"
|
|
1277
1290
|
}
|
|
1278
1291
|
|
|
1279
1292
|
cmd_hooks_install_dir() {
|
|
@@ -1390,6 +1403,7 @@ cmd_hooks() {
|
|
|
1390
1403
|
shift
|
|
1391
1404
|
_hook_name="$1"
|
|
1392
1405
|
shift || true
|
|
1406
|
+
export _RNEX_INSIDE_HOOK=1
|
|
1393
1407
|
require_workspace
|
|
1394
1408
|
case "$_hook_name" in
|
|
1395
1409
|
post-merge)
|
|
@@ -1403,6 +1417,9 @@ cmd_hooks() {
|
|
|
1403
1417
|
fi
|
|
1404
1418
|
fi
|
|
1405
1419
|
fi
|
|
1420
|
+
if [ -x "$NEXUS_DIR/.githooks/post-merge" ]; then
|
|
1421
|
+
"$NEXUS_DIR/.githooks/post-merge" "$@" || true
|
|
1422
|
+
fi
|
|
1406
1423
|
return 0
|
|
1407
1424
|
;;
|
|
1408
1425
|
post-commit)
|
|
@@ -1416,6 +1433,9 @@ cmd_hooks() {
|
|
|
1416
1433
|
fi
|
|
1417
1434
|
fi
|
|
1418
1435
|
fi
|
|
1436
|
+
if [ -x "$NEXUS_DIR/.githooks/post-commit" ]; then
|
|
1437
|
+
"$NEXUS_DIR/.githooks/post-commit" "$@" || true
|
|
1438
|
+
fi
|
|
1419
1439
|
return 0
|
|
1420
1440
|
;;
|
|
1421
1441
|
pre-commit)
|
|
@@ -1429,6 +1449,9 @@ cmd_hooks() {
|
|
|
1429
1449
|
fi
|
|
1430
1450
|
fi
|
|
1431
1451
|
fi
|
|
1452
|
+
if [ -x "$NEXUS_DIR/.githooks/pre-commit" ]; then
|
|
1453
|
+
"$NEXUS_DIR/.githooks/pre-commit" "$@" || return $?
|
|
1454
|
+
fi
|
|
1432
1455
|
return 0
|
|
1433
1456
|
;;
|
|
1434
1457
|
pre-push)
|
|
@@ -1438,6 +1461,9 @@ cmd_hooks() {
|
|
|
1438
1461
|
printf '%b[WIKI]%b Pre-push trigger: verifying wiki changes.\n' "$_C" "$_NC"
|
|
1439
1462
|
fi
|
|
1440
1463
|
fi
|
|
1464
|
+
if [ -x "$NEXUS_DIR/.githooks/pre-push" ]; then
|
|
1465
|
+
"$NEXUS_DIR/.githooks/pre-push" "$@" || return $?
|
|
1466
|
+
fi
|
|
1441
1467
|
return 0
|
|
1442
1468
|
;;
|
|
1443
1469
|
esac
|
|
@@ -2177,7 +2203,7 @@ cmd_fix() {
|
|
|
2177
2203
|
_cur_hp="$(git -C "$NEXUS_DIR" config --get core.hooksPath 2>/dev/null || true)"
|
|
2178
2204
|
if [ "$_cur_hp" != ".rnex/hooks" ] && [ "$_cur_hp" != "$NEXUS_DIR/.rnex/hooks" ]; then
|
|
2179
2205
|
cmd_hooks_install_dir "$NEXUS_DIR"
|
|
2180
|
-
|
|
2206
|
+
elif [ "${_RNEX_INSIDE_HOOK:-0}" -ne 1 ]; then
|
|
2181
2207
|
_hooks_dir="$NEXUS_DIR/.rnex/hooks"
|
|
2182
2208
|
_create_hook_script "$_hooks_dir/post-merge" "post-merge"
|
|
2183
2209
|
_create_hook_script "$_hooks_dir/post-commit" "post-commit"
|
|
@@ -2189,11 +2215,13 @@ cmd_fix() {
|
|
|
2189
2215
|
*)
|
|
2190
2216
|
_cur_hp="$(git -C "$NEXUS_DIR" config --get core.hooksPath 2>/dev/null || true)"
|
|
2191
2217
|
if [ "$_cur_hp" = ".rnex/hooks" ] || [ "$_cur_hp" = "$NEXUS_DIR/.rnex/hooks" ]; then
|
|
2192
|
-
|
|
2193
|
-
|
|
2194
|
-
|
|
2195
|
-
|
|
2196
|
-
|
|
2218
|
+
if [ "${_RNEX_INSIDE_HOOK:-0}" -ne 1 ]; then
|
|
2219
|
+
_hooks_dir="$NEXUS_DIR/.rnex/hooks"
|
|
2220
|
+
_create_hook_script "$_hooks_dir/post-merge" "post-merge"
|
|
2221
|
+
_create_hook_script "$_hooks_dir/post-commit" "post-commit"
|
|
2222
|
+
_create_hook_script "$_hooks_dir/pre-commit" "pre-commit"
|
|
2223
|
+
_create_hook_script "$_hooks_dir/pre-push" "pre-push"
|
|
2224
|
+
fi
|
|
2197
2225
|
fi
|
|
2198
2226
|
;;
|
|
2199
2227
|
esac
|