From 17f502588ef075a8e1242527879388d72826c3a4 Mon Sep 17 00:00:00 2001 From: David Runge Date: Fri, 5 Jan 2024 17:31:59 +0100 Subject: zsh: Update nvt wrapper to also track state changes in git Remove unnecessary curly braces. Add git integration for state dir to automatically push updated change to state git repo. Signed-off-by: David Runge --- .config/zsh/functions/packaging.zsh | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/.config/zsh/functions/packaging.zsh b/.config/zsh/functions/packaging.zsh index 69d6df4..d8c160c 100644 --- a/.config/zsh/functions/packaging.zsh +++ b/.config/zsh/functions/packaging.zsh @@ -104,24 +104,26 @@ nvc() { } nvt() { - local config package + local config_file package repo state_dir if [[ -z "$1" ]]; then 1>&2 printf "A repository name needs to be specified as the first argument.\n" return 1 fi - config="${HOME}/.config/nvchecker/$1.toml" - if [[ ! -f "${config}" ]]; then - 1>&2 printf "The configuration does not exist: %s\n" "${config}" + if [[ -z "$2" ]]; then + 1>&2 printf "A package name needs to be specified as the second argument.\n" return 1 fi - if [[ -z "$2" ]]; then - 1>&2 printf "A package name needs to be specified as the second argument.\n" + repo="$1" + config_file="$HOME/.config/nvchecker/$repo.toml" + if [[ ! -f "$config_file" ]]; then + 1>&2 printf "The configuration does not exist: %s\n" "$config_file" return 1 fi - package="${2}" - if ! grep "${package}" "${config}" > /dev/null; then - 1>&2 printf "The package %s can not be found in the configuration: %s\n" "${package}" "${config}" + + package="$2" + if ! grep "$package" "$config_file" > /dev/null; then + 1>&2 printf "The package %s can not be found in the configuration: %s\n" "$package" "$config_file" return 1 fi @@ -129,5 +131,11 @@ nvt() { 1>&2 printf "The required application 'nvtake' can not be found.\n" return 1 fi - nvtake -c "${config}" "${package}" + nvtake -c "$config_file" "$package" + + state_dir="$HOME/.local/state/nvchecker/" + git -C "$state_dir" add "$repo.*.json*" + git -C "$state_dir" commit -s -m "Update $package" + git -C "$state_dir" pull --rebase + git -C "$state_dir" push } -- cgit v1.2.3-54-g00ecf