aboutsummaryrefslogtreecommitdiffstats
path: root/.config/zsh
diff options
context:
space:
mode:
authorDavid Runge <dave@sleepmap.de>2024-01-05 17:31:59 +0100
committerDavid Runge <dave@sleepmap.de>2024-01-05 17:31:59 +0100
commit17f502588ef075a8e1242527879388d72826c3a4 (patch)
tree450ebfe480c13b522dfd693273e094f7ff77e134 /.config/zsh
parent2d8f0c8706a68c5704c08fc998cd2a6e140a3765 (diff)
downloaddotfiles-17f502588ef075a8e1242527879388d72826c3a4.tar.gz
dotfiles-17f502588ef075a8e1242527879388d72826c3a4.tar.bz2
dotfiles-17f502588ef075a8e1242527879388d72826c3a4.tar.xz
dotfiles-17f502588ef075a8e1242527879388d72826c3a4.zip
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 <dave@sleepmap.de>
Diffstat (limited to '.config/zsh')
-rw-r--r--.config/zsh/functions/packaging.zsh28
1 files 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
}