From f564153aae9c9ee218665024c7d50433414ef688 Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Mon, 17 Apr 2023 20:46:29 -0300 Subject: [PATCH] Add `__changed_files`, `__removed_files` --- libexec/portzap/commands/install | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/libexec/portzap/commands/install b/libexec/portzap/commands/install index cb4d424..2691150 100644 --- a/libexec/portzap/commands/install +++ b/libexec/portzap/commands/install @@ -1,5 +1,19 @@ #!/bin/sh +__changed_files() { + rev=$1 + echo $( + git diff --name-only --diff-filter=AM $rev..HEAD | \ + cut -d / -f1 -f2 | \ + uniq + ) +} + +__removed_files() { + rev=$1 + echo $(git diff --name-only --diff-filter=D $rev..HEAD) +} + install() { ports_dir=$1 portzap_dir=$2 @@ -9,13 +23,13 @@ install() { cd $portzap_dir if [ -e "$portzap_file" ]; then rev=$(cat $portzap_file) - nw_files=$(git diff --name-only --diff-filter=AM $rev..HEAD | cut -d / -f1 -f2 | uniq) - rm_files=$(git diff --name-only --diff-filter=D $rev..HEAD) + ch_files=$(eval __changed_files "$rev") + rm_files=$(eval __removed_files "$rev") for file in $rm_files; do echo RM $ports_dir/$file rm $ports_dir/$file done - for file in $nw_files; do + for file in $ch_files; do if [ -f "$file" ]; then echo $file $libexec_dir/install-file $ports_dir $file