From 6711abdfbff747ba75ff63f2987c6e91a8e3173a Mon Sep 17 00:00:00 2001 From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Mon, 16 Nov 2020 18:47:27 -0500 Subject: [PATCH] fix pull bug, add logging There was a bug where changed files would be `git pull`ed into the current working directory instead of the proper plugin directory, which is now fixed. Also, added some very basic logging to /tmp --- zpe.zsh | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/zpe.zsh b/zpe.zsh index eb31f0e..1061ce9 100755 --- a/zpe.zsh +++ b/zpe.zsh @@ -5,41 +5,41 @@ zpe_config_dir="${HOME}/.config/zpe/" zpe_plugin_dir="${zpe_config_dir}/plugins/" zpe_tmp_dir="/tmp/zpe/" +zpe_log_dir="/tmp/zpe/logs" zpe-meta-pre() { # Create necesary directories, check dependencies [[ -d "${zpe_config_dir}" ]] || mkdir -p "${zpe_config_dir}" [[ -d "${zpe_plugin_dir}" ]] || mkdir -p "${zpe_plugin_dir}" - [[ -d /tmp/zpe ]] || mkdir ${zpe_tmp_dir} + [[ -d "${zpe_tmp_dir}" ]] || mkdir ${zpe_tmp_dir} + [[ -d "${zpe_log_dir}" ]] || mkdir ${zpe_log_dir} touch "${zpe_config_dir}"repositories - [[ -x git ]] && echo "please install git" + [[ -x git ]] && echo "Please install git" } zpe-clone() { # Clone all the repos in the config file recursively into the plugin directory zpe-meta-pre - cat ${zpe_config_dir}repositories | xargs -P10 -I{} git -C ${zpe_plugin_dir} clone {} - echo "all plugins are downloaded" + cat ${zpe_config_dir}repositories | xargs -P10 -I{} git -C ${zpe_plugin_dir} clone {} -q --depth 1 &> "${zpe_log_dir}"/$(date -Iseconds) + echo "All plugins are downloaded" } zpe-pull() { # Recursively pull zpe-meta-pre local find_dirs=$(find "${zpe_plugin_dir}" -name ".git" -type d) - echo $find_dirs | xargs -P10 -I{} git --git-dir={} config pull.ff only - echo $find_dirs | xargs -P10 -I{} git --git-dir={} pull > /dev/null - echo "all plugins are up to date" + echo $find_dirs | xargs -P10 -I {} git --git-dir={} config pull.ff only + echo $find_dirs | xargs -P10 -I {} git --git-dir={} --work-tree={} pull &> "${zpe_log_dir}"/$(date -Iseconds) + echo "All plugins are up to date" } zpe-clean() { # Remove cloned plugins not specified in the config file zpe-meta-pre - echo -n "" > "${zpe_tmp_dir}"deletable - echo -n "" > "${zpe_tmp_dir}"diff - find ${zpe_plugin_dir} -maxdepth 1 -type d -exec git -C {} config --get remote.origin.url \; > "${zpe_tmp_dir}"installed-urls - comm -23 <(sort ${zpe_tmp_dir}installed-urls) <(sort "${zpe_config_dir}"repositories) >> "${zpe_tmp_dir}"/diff + comm -23 <(sort ${zpe_tmp_dir}installed-urls) <(sort "${zpe_config_dir}"repositories) > "${zpe_tmp_dir}"/diff + echo -n "" > "${zpe_tmp_dir}"deletable while read line; do grep -l $line "$zpe_plugin_dir"/*/.git/config >> "${zpe_tmp_dir}"deletable done < ${zpe_tmp_dir}diff -- 2.39.2