From e42f18fd5539182b6638987eeaffb6cb82f9e738 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 20 Dec 2024 20:10:40 +0100 Subject: fix(pkgs/neorg/inputs): Improve git integration and bound review --- pkgs/by-name/ne/neorg/functions/inputs.sh | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) (limited to 'pkgs/by-name/ne/neorg/functions/inputs.sh') diff --git a/pkgs/by-name/ne/neorg/functions/inputs.sh b/pkgs/by-name/ne/neorg/functions/inputs.sh index 52efcc47..d47b129a 100644 --- a/pkgs/by-name/ne/neorg/functions/inputs.sh +++ b/pkgs/by-name/ne/neorg/functions/inputs.sh @@ -1,5 +1,14 @@ #!/usr/bin/env dash +_git_commit() { + message="$1" + + cd "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" || die "BUG. This should exist." + [ -d .git ] || git init + git add . + git commit --message "$message" --no-gpg-sign +} + inputs0add() { url_file="$1" @@ -14,11 +23,7 @@ inputs0add() { } >>"%NEORG_INPUTS_STORAGE_FILE" && msg2 "Successfully added file '$url_file' with $(clean "$url_file" | wc -l) entries to the url list" - cd "$(dirname "%NEORG_INPUTS_STORAGE_FILE")" || die "BUG. This should exist." - - [ -d .git ] || git init - git add . - git commit --message "Add entries from '$url_file' ($(clean "$url_file" | wc -l))" --no-gpg-sign + _git_commit "Add entries from '$url_file' ($(clean "$url_file" | wc -l))" } inputs0review() { @@ -33,12 +38,16 @@ inputs0review() { # Give it some time to start up. sleep 2 - while read -r url; do - msg "Adding url '$url'" + if [ "$(wc -l <"%NEORG_INPUTS_STORAGE_FILE")" -gt 100 ]; then + echo "Your would want to review more than 100 inputs. Limiting it to the first 100 entries." + fi + + head --lines=100 "%NEORG_INPUTS_STORAGE_FILE" | while read -r url; do + echo "-> '$url'" firefox -P "$base_profile" "$url" echo "$url" >>"$done_urls" - done <"%NEORG_INPUTS_STORAGE_FILE" + done # Wait for the Firefox process from above to finish. wait @@ -48,6 +57,6 @@ inputs0review() { awk 'NR==FNR {a[$0]=1; next} !a[$0]' "$done_urls" "%NEORG_INPUTS_STORAGE_FILE" >"$tmp" mv "$tmp" "%NEORG_INPUTS_STORAGE_FILE" - git add . - git commit --message "Dump entries into firefox profile '$base_profile'" --no-gpg-sign + + _git_commit "Dump entries into firefox profile '$base_profile'" } -- cgit 1.4.1