eagle-mem 4.6.1 → 4.6.2
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/package.json +1 -1
- package/scripts/curate.sh +35 -25
package/package.json
CHANGED
package/scripts/curate.sh
CHANGED
|
@@ -398,46 +398,56 @@ if [ -n "$co_edit_data" ]; then
|
|
|
398
398
|
eagle_info " Co-edit pairs found:"
|
|
399
399
|
fi
|
|
400
400
|
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
401
|
+
# Use awk for associative map (Bash 3.2 compatible)
|
|
402
|
+
co_map_output=$(printf '%s\n' "$co_edit_data" | awk -F'|' '
|
|
403
|
+
$1 && $2 {
|
|
404
|
+
m[$1] = (m[$1] ? m[$1] "," : "") $2
|
|
405
|
+
m[$2] = (m[$2] ? m[$2] "," : "") $1
|
|
406
|
+
n++
|
|
407
|
+
}
|
|
408
|
+
END {
|
|
409
|
+
for (f in m) print f "|" m[f]
|
|
410
|
+
print "__co_edit_count__|" n "|" length(m) > "/dev/stderr"
|
|
411
|
+
}
|
|
412
|
+
' 2>&1 1>/dev/null)
|
|
413
|
+
# stderr has the count line, stdout has the map lines — reverse:
|
|
414
|
+
co_map_output=$(printf '%s\n' "$co_edit_data" | awk -F'|' '
|
|
415
|
+
$1 && $2 {
|
|
416
|
+
m[$1] = (m[$1] ? m[$1] "," : "") $2
|
|
417
|
+
m[$2] = (m[$2] ? m[$2] "," : "") $1
|
|
418
|
+
n++
|
|
419
|
+
}
|
|
420
|
+
END {
|
|
421
|
+
for (f in m) print f "|" m[f]
|
|
422
|
+
printf "%s\n", "__META__|" n "|" length(m) > "/dev/stderr"
|
|
423
|
+
}
|
|
424
|
+
' 2>/tmp/eagle_co_edit_meta)
|
|
425
|
+
co_edit_count=$(awk -F'|' '{print $2}' /tmp/eagle_co_edit_meta)
|
|
426
|
+
co_map_file_count=$(awk -F'|' '{print $3}' /tmp/eagle_co_edit_meta)
|
|
427
|
+
rm -f /tmp/eagle_co_edit_meta
|
|
420
428
|
|
|
421
429
|
if [ "$DRY_RUN" -eq 1 ]; then
|
|
422
|
-
|
|
423
|
-
|
|
430
|
+
printf '%s\n' "$co_map_output" | while IFS='|' read -r f partners; do
|
|
431
|
+
[ -z "$f" ] && continue
|
|
432
|
+
eagle_info " $(basename "$f") → $partners"
|
|
424
433
|
done
|
|
425
434
|
else
|
|
426
435
|
{
|
|
427
436
|
echo "BEGIN;"
|
|
428
437
|
echo "DELETE FROM file_hints WHERE project = '$(eagle_sql_escape "$project")' AND hint_type = 'co_edit';"
|
|
429
|
-
|
|
438
|
+
printf '%s\n' "$co_map_output" | while IFS='|' read -r f partners; do
|
|
439
|
+
[ -z "$f" ] && continue
|
|
430
440
|
local_f=$(eagle_sql_escape "$f")
|
|
431
|
-
local_v=$(eagle_sql_escape "$
|
|
441
|
+
local_v=$(eagle_sql_escape "$partners")
|
|
432
442
|
echo "INSERT INTO file_hints (project, hint_type, file_path, hint_value) VALUES ('$(eagle_sql_escape "$project")', 'co_edit', '$local_f', '$local_v') ON CONFLICT(project, hint_type, file_path) DO UPDATE SET hint_value = excluded.hint_value, updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now');"
|
|
433
443
|
done
|
|
434
444
|
echo "COMMIT;"
|
|
435
445
|
} | eagle_db_pipe
|
|
436
446
|
_proj_hash=$(printf '%s' "$project" | shasum | cut -c1-8)
|
|
437
447
|
touch "$EAGLE_MEM_DIR/.co-edit-active.${_proj_hash}"
|
|
438
|
-
eagle_log "INFO" "Curator: stored $
|
|
448
|
+
eagle_log "INFO" "Curator: stored $co_map_file_count co-edit hints from $co_edit_count pairs"
|
|
439
449
|
fi
|
|
440
|
-
eagle_ok "$co_edit_count co-edit pairs found ($
|
|
450
|
+
eagle_ok "$co_edit_count co-edit pairs found ($co_map_file_count files)"
|
|
441
451
|
else
|
|
442
452
|
if [ "$DRY_RUN" -eq 0 ]; then
|
|
443
453
|
eagle_delete_file_hints "$project" "co_edit"
|